├── .gitignore ├── .travis.yml ├── LICENCE ├── README.md ├── bowshock ├── __init__.py ├── apod.py ├── asterank.py ├── earth.py ├── helioviewer.py ├── helpers.py ├── maas.py ├── modis.py ├── patents.py ├── predictthesky.py ├── skymorph.py ├── star.py ├── techport.py └── temperature_anomalies.py ├── docs ├── bowshock.jpg └── bowshock2.png ├── requirements.txt ├── setup.py └── tests ├── test_apod.py ├── test_asterank.py ├── test_earth.py ├── test_helioviewer.py ├── test_maas.py ├── test_patents.py ├── test_predictthesky.py ├── test_skymorph.py ├── test_star.py ├── test_techport.py └── test_temperature_anomalies.py /.gitignore: -------------------------------------------------------------------------------- 1 | bowshock/*.pyc 2 | bowshock.egg-info/ 3 | build/ 4 | dist/ 5 | 6 | # Byte-compiled / optimized / DLL files 7 | __pycache__/ 8 | *.py[cod] 9 | 10 | # C extensions 11 | *.so 12 | 13 | # Distribution / packaging 14 | .Python 15 | env/ 16 | build/ 17 | develop-eggs/ 18 | dist/ 19 | downloads/ 20 | eggs/ 21 | lib/ 22 | lib64/ 23 | parts/ 24 | sdist/ 25 | var/ 26 | *.egg-info/ 27 | .installed.cfg 28 | *.egg 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .coverage 44 | .cache 45 | nosetests.xml 46 | coverage.xml 47 | 48 | # Translations 49 | *.mo 50 | *.pot 51 | 52 | # Django stuff: 53 | *.log 54 | 55 | # Sphinx documentation 56 | docs/_build/ 57 | 58 | # PyBuilder 59 | target/ 60 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | 3 | install: 4 | - "pip install -r requirements.txt" 5 | 6 | script: 7 | - python tests/test_apod.py 8 | - python tests/test_asterank.py 9 | - python tests/test_earth.py 10 | - python tests/test_helioviewer.py 11 | - python tests/test_maas.py 12 | # - python tests/test_patents.py 13 | # - python tests/test_predictthesky.py 14 | - python tests/test_skymorph.py 15 | - python tests/test_star.py 16 | - python tests/test_techport.py 17 | - python tests/test_temperature_anomalies.py 18 | 19 | 20 | notifications: 21 | email: false 22 | 23 | branches: 24 | only: 25 | - master 26 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Screenshot](https://raw.githubusercontent.com/emirozer/bowshock/master/docs/bowshock2.png) 2 | =========== 3 | [![PyPI version](https://badge.fury.io/py/bowshock.svg)](http://badge.fury.io/py/bowshock) 4 | [![Downloads](https://img.shields.io/pypi/dm/bowshock.svg)](https://img.shields.io/pypi/dm/bowshock.svg) 5 | [![Status](https://img.shields.io/pypi/status/bowshock.svg)](https://img.shields.io/pypi/status/bowshock.svg) 6 | [![Build Status](https://travis-ci.org/emirozer/bowshock.svg)](https://travis-ci.org/emirozer/bowshock) 7 | 8 | =========== 9 | 10 | ## About 11 | 12 | bowshock is an all-in-one wrapper for NASA API's. 13 | Here is a list of currently supported API's : 14 | 15 | * NASA [Earth API](https://api.nasa.gov/api.html#earth) 16 | * NASA [APOD (Astronomy Picture of the Day) API](https://api.nasa.gov/api.html#apod) 17 | * NASA [Patents API](https://api.nasa.gov/api.html#patents) 18 | * NASA [Earth Temperature Anomalies API](https://api.nasa.gov/api.html#earth-temperature-anomalies) 19 | * [Asterank API](http://www.asterank.com/api) 20 | * [HelioViewer API](http://helioviewer.org/api/docs/v1/) 21 | * [MAAS (Mars Weather) API](http://marsweather.ingenology.com/#get_started) 22 | * [MODIS (Land, Atmosphere and Ocean Data) API](http://daac.ornl.gov/MODIS/MODIS-menu/modis_webservice.html) 23 | * [Skymorph API](http://www.asterank.com/skymorph) 24 | * [Star API](http://hacktheuniverse.github.io/star-api/) 25 | * [Techport API](https://data.nasa.gov/developer/external/techport/techport-api.pdf) 26 | * [PredictTheSky API](http://predictthesky.org/developers.html) 27 | 28 | ## Install 29 | 30 | Standart Procedure 31 | 32 | pip install bowshock 33 | 34 | *Important Note*: The only requirement is the 'requests' package BUT if you want to use MODIS there is an external requirement which is 'suds' package 35 | 36 | ## Do i need an API Key ? 37 | 38 | YES | NO 39 | ------ |---- 40 | Earth |The rest 41 | APOD | 42 | Patents | 43 | Earth Temperature Anomalies| 44 | 45 | **The rest does not require an API key for usage.** 46 | Get your NASA API KEY from : https://data.nasa.gov/developer/external/planetary/#apply-for-an-api-key 47 | 48 | #### Setting up the API Key 49 | =================== 50 | set an environment varible NASA_API_KEY which is equal to your key string 51 | 52 | 53 | ## Usage 54 | 55 | - 56 | ##### Apod 57 | ```python 58 | from bowshock import apod 59 | 60 | # with specific date and tags - For apod all args are optional 61 | apod.apod(date="2015-02-02", concept_tags=True) 62 | 63 | ``` 64 | 65 | - 66 | ##### Asterank 67 | ```python 68 | from bowshock import asterank 69 | 70 | # all args mandatory 71 | asterank.asterank( 72 | query={"e": {"$lt": 0.1}, 73 | "i": {"$lt": 4}, 74 | "a": {"$lt": 1.5}}, 75 | limit=1) 76 | 77 | ``` 78 | 79 | 80 | - 81 | ##### Earth 82 | ```python 83 | from bowshock import earth 84 | 85 | # imagery endpoint lon & lat mandatory, rest optional 86 | earth.imagery(lon=100.75, 87 | lat=1.6, 88 | dim=0.0025, 89 | date="2015-02-02", 90 | cloud_score=True) 91 | # assets endpoint lon & lat & begin mandatory, end optional 92 | earth.assets(lon=100.75, lat=1.6, begin="2015-02-02", end="2015-02-10") 93 | ``` 94 | 95 | - 96 | ##### HelioViewer 97 | ```python 98 | from bowshock import helioviewer 99 | 100 | # args are mandatory 101 | helioviewer.getjp2image(date='2014-01-01T23:59:59', sourceId=14) 102 | #args are mandatory 103 | helioviewer.getjp2header(Id=7654321) 104 | 105 | ``` 106 | 107 | 108 | - 109 | ##### MAAS 110 | ```python 111 | from bowshock import maas 112 | 113 | # mandatory date begin / end 114 | maas.maas_archive('2012-10-01', '2012-10-31') 115 | 116 | maas.maas_latest() 117 | 118 | ``` 119 | 120 | - 121 | ##### Patents 122 | ```python 123 | from bowshock import patents 124 | 125 | # only query is mandatory, rest is optional 126 | patents.patents(query="temperature", concept_tags=True, limit=5) 127 | 128 | ``` 129 | 130 | 131 | - 132 | ##### PredictTheSky 133 | ```python 134 | from bowshock import predictthesky 135 | 136 | #args are mandatory 137 | predictthesky.space_events(lon=100.75, lat=1.5) 138 | 139 | ``` 140 | 141 | 142 | - 143 | ##### Star API 144 | ```python 145 | from bowshock import star 146 | 147 | star.stars() 148 | star.search_star("Sun") 149 | 150 | star.exoplanets() 151 | star.search_exoplanet("11 Com") 152 | 153 | star.local_group_of_galaxies() 154 | star.search_local_galaxies("IC 10") 155 | 156 | star.star_clusters() 157 | star.search_star_cluster("Berkeley 59") 158 | 159 | ``` 160 | 161 | 162 | - 163 | ##### Skymorph 164 | ```python 165 | from bowshock import skymorph 166 | 167 | # mandatory obj id 168 | skymorph.search_target_obj("J99TS7A") 169 | 170 | #TODO : add search_position() , search_target_obj() 171 | 172 | ``` 173 | 174 | 175 | - 176 | ##### temperature anomalies 177 | ```python 178 | from bowshock import temperature_anomalies 179 | 180 | # end arg is optional, rest is mandatory 181 | temperature_anomalies.coordinate(lon=100.3, lat=1.6, begin="1990", end="2005") 182 | 183 | 184 | ``` 185 | 186 | 187 | - 188 | ##### techport 189 | ```python 190 | from bowshock import techport 191 | 192 | techport.techport(Id="4795") 193 | 194 | ``` 195 | ## Contributors 196 | 197 | * [Dan Wagner](https://github.com/danwagnerco) 198 |
199 | 200 | ## TODO 201 | - Lance-Modis API - http://lance-modis.eosdis.nasa.gov/user_services/api-lance.html 202 | 203 | ## BTW What is "bowshock"? 204 | ![Screenshot](https://raw.githubusercontent.com/emirozer/bowshock/master/docs/bowshock.jpg) 205 | -------------------------------------------------------------------------------- /bowshock/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | bowshock 4 | ~~~~~~~~ 5 | """ 6 | 7 | __title__ = 'bowshock' 8 | __version__ = '0.0.2' 9 | __author__ = 'Emir Ozer' 10 | __license__ = 'GNU General Public License' 11 | 12 | import bowshock.apod 13 | import bowshock.asterank 14 | import bowshock.earth 15 | import bowshock.helioviewer 16 | import bowshock.maas 17 | # from bowshock.modis import * 18 | import bowshock.patents 19 | import bowshock.predictthesky 20 | import bowshock.skymorph 21 | import bowshock.star 22 | import bowshock.techport 23 | import bowshock.temperature_anomalies 24 | 25 | -------------------------------------------------------------------------------- /bowshock/apod.py: -------------------------------------------------------------------------------- 1 | # One of the most popular websites at NASA is the Astronomy Picture of the Day. In fact, this website is one of the most popular websites across all federal agencies. 2 | # It has the popular appeal of a Justin Bieber video. This endpoint structures the APOD imagery and associated metadata so that it can be repurposed for other applications. 3 | # In addition, if the concept_tags parameter is set to True, then keywords derived from the image explanation are returned. These keywords could be used as auto-generated hashtags for twitter or instagram feeds; but generally help with discoverability of relevant imagery. 4 | from bowshock.helpers import nasa_api_key, bowshock_logger, vali_date, dispatch_http_get 5 | 6 | logger = bowshock_logger() 7 | 8 | 9 | def apod(date=None, concept_tags=None): 10 | ''' 11 | HTTP REQUEST 12 | 13 | GET https://api.nasa.gov/planetary/apod 14 | 15 | QUERY PARAMETERS 16 | 17 | Parameter Type Default Description 18 | date YYYY-MM-DD today The date of the APOD image to retrieve 19 | concept_tags bool False Return an ordered dictionary of concepts from the APOD explanation 20 | api_key string DEMO_KEY api.nasa.gov key for expanded usage 21 | EXAMPLE QUERY 22 | 23 | https://api.nasa.gov/planetary/apod?concept_tags=True&api_key=DEMO_KEY 24 | ''' 25 | base_url = "https://api.nasa.gov/planetary/apod?" 26 | 27 | if date: 28 | try: 29 | vali_date(date) 30 | base_url += "date=" + date + "&" 31 | except: 32 | raise ValueError("Incorrect date format, should be YYYY-MM-DD") 33 | if concept_tags == True: 34 | base_url += "concept_tags=True" + "&" 35 | 36 | req_url = base_url + "api_key=" + nasa_api_key() 37 | 38 | return dispatch_http_get(req_url) 39 | -------------------------------------------------------------------------------- /bowshock/asterank.py: -------------------------------------------------------------------------------- 1 | # http://www.asterank.com/api 2 | # The Asterank database is a thin layer over the NASA/JPL Small Body Database, merged with JPL delta-v data, published asteroid mass data, 3 | # and their own calculations. 4 | 5 | #The database currently runs on mongodb and queries must adhere to mongo's json format for a 'find' operation. 6 | import json 7 | from bowshock.helpers import bowshock_logger, dispatch_http_get 8 | 9 | logger = bowshock_logger() 10 | 11 | 12 | def asterank(query=None, limit=None): 13 | ''' 14 | Format 15 | Requests are of the form: 16 | 17 | http://asterank.com/api/asterank?query={query}&limit={limit} 18 | Response data formats are largely derived from NASA/JPL's Small Body Database query browser. Exceptions to this are the delta-v field (dv), the mass field (GM), and the normalized spectral type field (spec). Additional Asterank scores are included: closeness, price ($), and overall score. 19 | 20 | Sample Request 21 | This request returns an asteroid with a roughly circular orbit, low inclination, and semi-major axis less than 1.5 AU: 22 | 23 | /api/asterank?query={"e":{"$lt":0.1},"i":{"$lt":4},"a":{"$lt":1.5}}&limit=1 24 | 25 | ''' 26 | 27 | base_url = "http://asterank.com/api/asterank?" 28 | 29 | if query: 30 | try: 31 | query = json.dumps(query) 32 | 33 | base_url += "query=" + query + "&" 34 | except: 35 | raise ValueError("query= param is not valid json.") 36 | else: 37 | raise ValueError( 38 | "query= param is missing, expecting json data format.") 39 | 40 | if limit: 41 | if not isinstance(limit, int): 42 | logger.error( 43 | "The limit arg you provided is not the type of int, ignoring it") 44 | base_url += "limit=" + str(limit) 45 | else: 46 | raise ValueError("limit= param is missing, expecting int") 47 | 48 | return dispatch_http_get(base_url) 49 | -------------------------------------------------------------------------------- /bowshock/earth.py: -------------------------------------------------------------------------------- 1 | # This endpoint retrieves the Landsat 8 image for the supplied location and date. 2 | # The response will include the date and URL to the image that is closest to the supplied date. 3 | # The requested resource may not be available for the exact date in the request. You can retrieve a list of available resources through the assets endpoint. 4 | 5 | # The cloud score is an optional calculation that returns the percentage of the queried image that is covered by clouds. 6 | # If False is supplied to the cloud_score parameter, then no keypair is returned. 7 | # If True is supplied, then a keypair will always be returned, even if the backend algorithm is not able to calculate a score. 8 | #Note that this is a rough calculation, mainly used to filter out exceedingly cloudy images. 9 | import decimal 10 | 11 | from bowshock.helpers import nasa_api_key, bowshock_logger, vali_date, validate_float, dispatch_http_get 12 | 13 | logger = bowshock_logger() 14 | 15 | 16 | def imagery(lon=None, lat=None, dim=None, date=None, cloud_score=None): 17 | ''' 18 | # ----------QUERY PARAMETERS---------- 19 | 20 | # Parameter Type Default Description 21 | # lat float n/a Latitude 22 | # lon float n/a Longitude 23 | # dim float 0.025 width and height of image in degrees 24 | # date YYYY-MM-DD today date of image ----if not supplied, then the most recent image (i.e., closest to today) is returned 25 | #cloud_score bool False calculate the percentage of the image covered by clouds 26 | #api_key string vDEMO_KEY api.nasa.gov key for expanded usage 27 | 28 | # ---------EXAMPLE QUERY-------- 29 | 30 | # https://api.nasa.gov/planetary/earth/imagery?lon=100.75&lat=1.5&date=2014-02-01&cloud_score=True&api_key=DEMO_KEY 31 | 32 | ''' 33 | 34 | base_url = "https://api.nasa.gov/planetary/earth/imagery?" 35 | 36 | if not lon or not lat: 37 | raise ValueError( 38 | "imagery endpoint expects lat and lon, type has to be float. Call the method with keyword args. Ex : lon=100.75, lat=1.5") 39 | else: 40 | try: 41 | validate_float(lon, lat) 42 | # Floats are entered/displayed as decimal numbers, but your computer 43 | # (in fact, your standard C library) stores them as binary. 44 | # You get some side effects from this transition: 45 | # >>> print len(repr(0.1)) 46 | # 19 47 | # >>> print repr(0.1) 48 | # 0.10000000000000001 49 | # Thus using decimal to str transition is more reliant 50 | lon = decimal.Decimal(lon) 51 | lat = decimal.Decimal(lat) 52 | base_url += "lon=" + str(lon) + "&" + "lat=" + str(lat) + "&" 53 | except: 54 | raise ValueError( 55 | "imagery endpoint expects lat and lon, type has to be float. Call the method with keyword args. Ex : lon=100.75, lat=1.5") 56 | 57 | if dim: 58 | try: 59 | validate_float(dim) 60 | dim = decimal.Decimal(dim) 61 | base_url += "dim=" + str(dim) + "&" 62 | except: 63 | raise ValueError("imagery endpoint expects dim to be a float") 64 | 65 | if date: 66 | try: 67 | vali_date(date) 68 | base_url += "date=" + date + "&" 69 | except: 70 | raise ValueError("Incorrect date format, should be YYYY-MM-DD") 71 | 72 | if cloud_score == True: 73 | base_url += "cloud_score=True" + "&" 74 | 75 | req_url = base_url + "api_key=" + nasa_api_key() 76 | 77 | return dispatch_http_get(req_url) 78 | 79 | # This endpoint retrieves the date-times and asset names for available imagery for a supplied location. 80 | # The satellite passes over each point on earth roughly once every sixteen days. 81 | # This is an amazing visualization of the acquisition pattern for Landsat 8 imagery. 82 | # The objective of this endpoint is primarily to support the use of the imagery endpoint. 83 | 84 | 85 | def assets(lon=None, lat=None, begin=None, end=None): 86 | ''' 87 | HTTP REQUEST 88 | 89 | GET https://api.nasa.gov/planetary/earth/assets 90 | 91 | QUERY PARAMETERS 92 | 93 | Parameter Type Default Description 94 | lat float n/a Latitude 95 | lon float n/a Longitude 96 | begin YYYY-MM-DD n/a beginning of date range 97 | end YYYY-MM-DD today end of date range 98 | api_key string DEMO_KEY api.nasa.gov key for expanded usage 99 | EXAMPLE QUERY 100 | 101 | https://api.nasa.gov/planetary/earth/assets?lon=100.75&lat=1.5&begin=2014-02-01&api_key=DEMO_KEY 102 | ''' 103 | base_url = "https://api.nasa.gov/planetary/earth/assets?" 104 | 105 | if not lon or not lat: 106 | raise ValueError( 107 | "assets endpoint expects lat and lon, type has to be float. Call the method with keyword args. Ex : lon=100.75, lat=1.5") 108 | else: 109 | try: 110 | validate_float(lon, lat) 111 | # Floats are entered/displayed as decimal numbers, but your computer 112 | # (in fact, your standard C library) stores them as binary. 113 | # You get some side effects from this transition: 114 | # >>> print len(repr(0.1)) 115 | # 19 116 | # >>> print repr(0.1) 117 | # 0.10000000000000001 118 | # Thus using decimal to str transition is more reliant 119 | lon = decimal.Decimal(lon) 120 | lat = decimal.Decimal(lat) 121 | base_url += "lon=" + str(lon) + "&" + "lat=" + str(lat) + "&" 122 | except: 123 | raise ValueError( 124 | "assets endpoint expects lat and lon, type has to be float. Call the method with keyword args. Ex : lon=100.75, lat=1.5") 125 | 126 | if not begin: 127 | raise ValueError( 128 | "Begin date is missing, which is mandatory. Format : YYYY-MM-DD") 129 | else: 130 | try: 131 | vali_date(begin) 132 | base_url += "begin=" + begin + "&" 133 | except: 134 | raise ValueError("Incorrect date format, should be YYYY-MM-DD") 135 | 136 | if end: 137 | try: 138 | vali_date(end) 139 | base_url += "end=" + end + "&" 140 | except: 141 | raise ValueError("Incorrect date format, should be YYYY-MM-DD") 142 | 143 | req_url = base_url + "api_key=" + nasa_api_key() 144 | 145 | return dispatch_http_get(req_url) 146 | -------------------------------------------------------------------------------- /bowshock/helioviewer.py: -------------------------------------------------------------------------------- 1 | # TODO: Complete helioviewer sdk 2 | 3 | # http://helioviewer.org/api/docs/v1/ 4 | # The Helioviewer Project maintains a set of Public APIs with the goal of improving access to solar and heliospheric datasets to scientists, educators, developers, and the general public. Read below for descriptions of each API endpoint and examples of usage. 5 | from bowshock.helpers import bowshock_logger, validate_iso8601, dispatch_http_get 6 | 7 | logger = bowshock_logger() 8 | 9 | 10 | def getjp2image(date, 11 | sourceId=None, 12 | observatory=None, 13 | instrument=None, 14 | detector=None, 15 | measurement=None): 16 | ''' 17 | Helioviewer.org and JHelioviewer operate off of JPEG2000 formatted image data generated from science-quality FITS files. Use the APIs below to interact directly with these intermediary JPEG2000 files. 18 | 19 | Download a JP2 image for the specified datasource that is the closest match in time to the `date` requested. 20 | 21 | Either `sourceId` must be specified, or the combination of `observatory`, `instrument`, `detector`, and `measurement`. 22 | 23 | Request Parameters: 24 | 25 | Parameter Required Type Example Description 26 | date Required string 2014-01-01T23:59:59Z Desired date/time of the JP2 image. ISO 8601 combined UTC date and time UTC format. 27 | sourceId Optional number 14 Unique image datasource identifier. 28 | observatory Optional string SDO Observatory name. 29 | instrument Optional string AIA Instrument name. 30 | detector Optional string AIA Detector name. 31 | measurement Optional string 335 Measurement name. 32 | jpip Optional boolean false Optionally return a JPIP URI instead of the binary data of the image itself. 33 | json Optional boolean false Optionally return a JSON object. 34 | 35 | 36 | EXAMPLE: http://helioviewer.org/api/v1/getJP2Image/?date=2014-01-01T23:59:59Z&sourceId=14&jpip=true 37 | ''' 38 | 39 | base_url = 'http://helioviewer.org/api/v1/getJP2Image/?' 40 | req_url = '' 41 | 42 | try: 43 | validate_iso8601(date) 44 | if not date[-1:] == 'Z': 45 | date += 'Z' 46 | base_url += 'date=' + date 47 | except: 48 | raise ValueError( 49 | "Your date input is not in iso8601 format. ex: 2014-01-01T23:59:59") 50 | 51 | if sourceId: 52 | if not isinstance(sourceId, int): 53 | logger.error("The sourceId argument should be an int, ignoring it") 54 | else: 55 | base_url += "sourceId=" + str(sourceId) + "&" 56 | 57 | if observatory: 58 | if not isinstance(observatory, str): 59 | logger.error( 60 | "The observatory argument should be a str, ignoring it") 61 | else: 62 | base_url += "observatory=" + observatory + "&" 63 | 64 | if instrument: 65 | if not isinstance(instrument, str): 66 | logger.error( 67 | "The instrument argument should be a str, ignoring it") 68 | else: 69 | base_url += "instrument=" + instrument + "&" 70 | if detector: 71 | if not isinstance(detector, str): 72 | logger.error("The detector argument should be a str, ignoring it") 73 | else: 74 | base_url += "detector=" + detector + "&" 75 | 76 | if measurement: 77 | if not isinstance(measurement, str): 78 | logger.error( 79 | "The measurement argument should be a str, ignoring it") 80 | else: 81 | base_url += "measurement=" + detector + "&" 82 | 83 | req_url += base_url + "jpip=true" 84 | 85 | return dispatch_http_get(req_url) 86 | 87 | 88 | def getjp2header(Id): 89 | ''' 90 | GET /api/v1/getJP2Header/ 91 | 92 | 93 | Get the XML header embedded in a JPEG2000 image. Includes the FITS header as well as a section of Helioviewer-specific metadata. 94 | 95 | Request Parameters: 96 | 97 | Parameter Required Type Example Description 98 | id Required number 7654321 Unique JP2 image identifier. 99 | callback Optional string Wrap the response object in a function call of your choosing. 100 | 101 | Example (A): 102 | 103 | string (XML) 104 | 105 | Example Request: 106 | 107 | http://helioviewer.org/api/v1/getJP2Header/?id=7654321 108 | ''' 109 | base_url = 'http://helioviewer.org/api/v1/getJP2Header/?' 110 | 111 | if not isinstance(Id, int): 112 | raise ValueError("The Id argument should be an int, ignoring it") 113 | else: 114 | base_url += "id=" + str(Id) 115 | 116 | return dispatch_http_get(base_url) 117 | -------------------------------------------------------------------------------- /bowshock/helpers.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import logging 3 | import datetime 4 | import os 5 | 6 | 7 | def bowshock_logger(): 8 | '''creates a logger obj''' 9 | 10 | FORMAT = '%(asctime)-15s %(message)s' 11 | logging.basicConfig(format=FORMAT, level=logging.INFO) 12 | logger = logging.getLogger('bowshock_logger') 13 | 14 | return logger 15 | 16 | 17 | logger = bowshock_logger() 18 | 19 | 20 | def dispatch_http_get(url): 21 | 22 | logger.warning("Dispatching HTTP GET Request : %s ", url) 23 | 24 | response = requests.get(url) 25 | 26 | logger.warning("Retrieved response: %s", response.text) 27 | 28 | return response 29 | 30 | 31 | def nasa_api_key(): 32 | ''' 33 | Returns personal api key. 34 | You can acquire one from here : 35 | https://data.nasa.gov/developer/external/planetary/#apply-for-an-api-key 36 | IMPORTANT: SET YOUR API KEY AS AN ENVIRONMENT VARIABLE. 37 | ''' 38 | 39 | api_key = os.environ["NASA_API_KEY"] 40 | 41 | return api_key 42 | 43 | 44 | def vali_date(date_text): 45 | try: 46 | datetime.datetime.strptime(date_text, '%Y-%m-%d') 47 | except ValueError: 48 | raise ValueError("Incorrect date format, should be YYYY-MM-DD") 49 | 50 | 51 | def validate_year(date_text): 52 | try: 53 | datetime.datetime.strptime(date_text, '%Y') 54 | except ValueError: 55 | raise ValueError("Incorrect date format, should be YYYY") 56 | 57 | 58 | def validate_float(*args): 59 | for arg in args: 60 | if isinstance(arg, float): 61 | return True 62 | else: 63 | raise ValueError("Expected float for argument") 64 | 65 | 66 | def validate_iso8601(date_text): 67 | try: 68 | datetime.datetime.strptime(date_text, '%Y-%m-%dT%H:%M:%S') 69 | except ValueError: 70 | raise ValueError("Incorrect date format, should be YYYY") 71 | -------------------------------------------------------------------------------- /bowshock/maas.py: -------------------------------------------------------------------------------- 1 | # http://marsweather.ingenology.com/#get_started 2 | 3 | # Below description taken from https://github.com/ingenology/mars_weather_api 4 | # The {MAAS} API is an open source REST API built to help make it easier and more efficient to build interactive applications that want to utilize the wealth of weather data being transmitted by the Curiosity Rover on Mars. Our API is built upon the REMS (Rover Environmental Monitoring Station) data provided by the Centro de Astrobiologia (CSIC-INTA). 5 | # This API is built on Django and Django REST Framework. 6 | # Our implementation of the API is available at marsweather.ingenology.com. 7 | import decimal 8 | 9 | from bowshock.helpers import nasa_api_key, bowshock_logger, vali_date, validate_float, dispatch_http_get 10 | 11 | logger = bowshock_logger() 12 | 13 | 14 | def maas_latest(): 15 | ''' 16 | will return a JSON object for the latest report: 17 | 18 | { 19 | "report": { 20 | "terrestrial_date": "2013-05-01", 21 | "sol": 261, 22 | "ls": 310.5, 23 | "min_temp": -69.75, 24 | "min_temp_fahrenheit": -93.55, 25 | "max_temp": -4.48, 26 | "max_temp_fahrenheit": 23.94, 27 | "pressure": 868.05, 28 | "pressure_string": "Higher", 29 | "abs_humidity": null, 30 | "wind_speed": null, 31 | "wind_direction": "--", 32 | "atmo_opacity": "Sunny", 33 | "season": "Month 11", 34 | "sunrise": "2013-05-01T11:00:00Z", 35 | "sunset": "2013-05-01T22:00:00Z" 36 | } 37 | } 38 | 39 | ''' 40 | base_url = 'http://marsweather.ingenology.com/v1/latest/' 41 | 42 | return dispatch_http_get(base_url) 43 | 44 | 45 | def maas_archive(begin, end): 46 | ''' 47 | This returns a collection of JSON objects for every weather report available for October 2012: 48 | 49 | { 50 | "count": 29, 51 | "next": "http://marsweather.ingenology.com/v1/archive/?terrestrial_date_end=2012-10-31&terrestrial_date_start=2012-10-01&page=2", 52 | "previous": null, 53 | "results": [ 54 | ... 55 | ] 56 | } 57 | ''' 58 | 59 | base_url = 'http://marsweather.ingenology.com/v1/archive/?' 60 | try: 61 | vali_date(begin) 62 | vali_date(end) 63 | base_url += 'terrestrial_date_start=' + begin + "&" + 'terrestrial_date_end=' + end 64 | except: 65 | raise ValueError("Incorrect date format, should be YYYY-MM-DD") 66 | 67 | return dispatch_http_get(base_url) 68 | -------------------------------------------------------------------------------- /bowshock/modis.py: -------------------------------------------------------------------------------- 1 | # I AM NOT THE ORIGINAL AUTHOR of this specific piece - emir 2 | # this is an implementation they provide over at their website 3 | # so i did some changes, cleanup and housekeeping & provided here 4 | # http://daac.ornl.gov/MODIS/MODIS-menu/modis_webservice.html 5 | # http://daac.ornl.gov/MODIS/MODIS-menu/other/MODIS_webservice_WSDL.txt 6 | 7 | import sys, os 8 | import numpy as np 9 | import optparse 10 | import pickle 11 | from copy import copy 12 | from suds.client import * 13 | 14 | base_url = 'http://daac.ornl.gov/cgi-bin/MODIS/GLBVIZ_1_Glb_subset/MODIS_webservice.wsdl' 15 | 16 | 17 | class modisData(object): 18 | def __init__(self): 19 | 20 | self.server = None 21 | self.product = None 22 | self.latitude = None 23 | self.longitude = None 24 | 25 | self.band = None 26 | self.nrows = None 27 | self.ncols = None 28 | self.cellsize = None 29 | self.scale = None 30 | self.units = None 31 | self.yllcorner = None 32 | self.xllcorner = None 33 | 34 | self.kmAboveBelow = 0 35 | self.kmLeftRight = 0 36 | 37 | self.dateStr = [] 38 | self.dateInt = [] 39 | self.data = [] 40 | self.QA = [] 41 | 42 | #self.header=None 43 | #self.subset=None 44 | 45 | self.isScaled = False 46 | 47 | def getFilename(self): 48 | 49 | d = '.' 50 | 51 | fn = self.product 52 | fn = fn + d + self.band 53 | fn = fn + d + 'LAT__' + str(self.latitude) 54 | fn = fn + d + 'LON__' + str(self.longitude) 55 | fn = fn + d + self.dateStr[0] 56 | fn = fn + d + self.dateStr[-1] 57 | fn = fn + d + str(int(self.nrows)) 58 | fn = fn + d + str(int(self.ncols)) 59 | 60 | return fn 61 | 62 | def pickle(self): 63 | 64 | fn = self.getFilename() + '.' + 'pkl' 65 | 66 | f = open(fn, 'w') 67 | pickle.dump(self, f) 68 | f.close() 69 | 70 | def applyScale(self): 71 | 72 | if self.isScaled == False: 73 | self.data = self.data * self.scale 74 | self.isScaled = True 75 | 76 | def filterQA(self, QAOK, fill=np.nan): 77 | 78 | if np.size(self.data) != np.size(self.QA): 79 | #should do this using an exception 80 | print >> sys.stderr, 'data and QA are different sizes' 81 | sys.exit() 82 | 83 | r = np.shape(self.data)[0] 84 | c = np.shape(self.data)[1] 85 | 86 | for i in xrange(c): 87 | for j in xrange(r): 88 | if np.sum(QAOK == self.QA[j][i]) == 0: 89 | self.data[j][i] = fill 90 | 91 | 92 | def __getDummyDateList(): 93 | """ 94 | Generate a dummy date list for testing without 95 | hitting the server 96 | """ 97 | 98 | D = [] 99 | for y in xrange(2001, 2010): 100 | for d in xrange(1, 365, 1): 101 | D.append('A%04d%03d' % (y, d)) 102 | 103 | return D 104 | 105 | 106 | def __error(msg): 107 | raise Exception, msg 108 | 109 | 110 | def latLonErr(): 111 | __error('Latitude and longitude must both be specified') 112 | 113 | 114 | def serverDataErr(): 115 | __error('Server not returning data (possibly busy)') 116 | 117 | 118 | def mkIntDate(s): 119 | """ 120 | Convert the webserver formatted dates 121 | to an integer format by stripping the 122 | leading char and casting 123 | """ 124 | n = s.__len__() 125 | d = int(s[-(n - 1):n]) 126 | 127 | return d 128 | 129 | 130 | def setClient(wsdlurl=base_url): 131 | 132 | return Client(wsdlurl) 133 | 134 | 135 | def printList(l): 136 | 137 | for i in xrange(l.__len__()): 138 | print l[i] 139 | 140 | 141 | def printModisData(m): 142 | 143 | print 'server:', m.server 144 | print 'product:', m.product 145 | print 'latitude:', m.latitude 146 | print 'longitude:', m.longitude 147 | 148 | print 'band:', m.band 149 | print 'nrows:', m.nrows 150 | print 'ncols:', m.ncols 151 | print 'cellsize:', m.cellsize 152 | print 'scale:', m.scale 153 | print 'units:', m.units 154 | print 'xllcorner:', m.yllcorner 155 | print 'yllcorner:', m.xllcorner 156 | 157 | print 'kmAboveBelow:', m.kmAboveBelow 158 | print 'kmLeftRight:', m.kmLeftRight 159 | 160 | print 'dates:', m.dateStr 161 | 162 | print 'QA:', m.QA 163 | print m.data 164 | 165 | 166 | def modisGetQA(m, QAname, client=None, chunkSize=8): 167 | 168 | startDate = m.dateInt[0] 169 | endDate = m.dateInt[-1] 170 | 171 | q = modisClient(client, 172 | product=m.product, 173 | band=QAname, 174 | lat=m.latitude, 175 | lon=m.longitude, 176 | startDate=startDate, 177 | endDate=endDate, 178 | chunkSize=chunkSize, 179 | kmAboveBelow=m.kmAboveBelow, 180 | kmLeftRight=m.kmLeftRight) 181 | 182 | m.QA = copy(q.data) 183 | 184 | 185 | def modisClient(client=None, 186 | product=None, 187 | band=None, 188 | lat=None, 189 | lon=None, 190 | startDate=None, 191 | endDate=None, 192 | chunkSize=8, 193 | kmAboveBelow=0, 194 | kmLeftRight=0): 195 | """ 196 | modisClient: function for building a modisData object 197 | """ 198 | 199 | m = modisData() 200 | 201 | m.kmABoveBelow = kmAboveBelow 202 | m.kmLeftRight = kmLeftRight 203 | 204 | if client == None: 205 | client = setClient() 206 | 207 | m.server = client.wsdl.url 208 | 209 | if product == None: 210 | prodList = client.service.getproducts() 211 | return prodList 212 | 213 | m.product = product 214 | 215 | if band == None: 216 | bandList = client.service.getbands(product) 217 | return bandList 218 | 219 | m.band = band 220 | 221 | if lat == None or lon == None: 222 | latLonErr() 223 | 224 | m.latitude = lat 225 | m.longitude = lon 226 | 227 | # get the date list regardless so we can 228 | # process it into appropriately sized chunks 229 | 230 | dateList = client.service.getdates(lat, lon, product) 231 | 232 | if startDate == None or endDate == None: 233 | return dateList 234 | 235 | #count up the total number of dates 236 | i = -1 237 | nDates = 0 238 | while i < dateList.__len__() - 1: 239 | i = i + 1 240 | 241 | thisDate = mkIntDate(dateList[i]) 242 | 243 | if thisDate < startDate: 244 | continue 245 | if thisDate > endDate: 246 | break 247 | 248 | nDates = nDates + 1 249 | 250 | m.dateInt.append(thisDate) 251 | m.dateStr.append(dateList[i]) 252 | 253 | n = 0 254 | i = -1 255 | while i < dateList.__len__() - 1: 256 | i = i + 1 257 | 258 | thisDate = mkIntDate(dateList[i]) 259 | 260 | if thisDate < startDate: 261 | continue 262 | if thisDate > endDate: 263 | break 264 | 265 | requestStart = dateList[i] 266 | 267 | j = min(chunkSize, dateList.__len__() - i) 268 | 269 | while mkIntDate(dateList[i + j - 1]) > endDate: 270 | j = j - 1 271 | 272 | requestEnd = dateList[i + j - 1] 273 | i = i + j - 1 274 | 275 | data = client.service.getsubset(lat, lon, product, band, requestStart, 276 | requestEnd, kmAboveBelow, kmLeftRight) 277 | 278 | # now fill up the data structure with the returned data... 279 | 280 | if n == 0: 281 | 282 | m.nrows = data.nrows 283 | m.ncols = data.ncols 284 | m.cellsize = data.cellsize 285 | m.scale = data.scale 286 | m.units = data.units 287 | m.yllcorner = data.yllcorner 288 | m.xllcorner = data.xllcorner 289 | 290 | m.data = np.zeros((nDates, m.nrows * m.ncols)) 291 | 292 | for j in xrange(data.subset.__len__()): 293 | kn = 0 294 | 295 | for k in data.subset[j].split(",")[5:]: 296 | 297 | try: 298 | m.data[n * chunkSize + j, kn] = int(k) 299 | except ValueError: 300 | serverDataErr() 301 | 302 | kn = kn + 1 303 | 304 | n = n + 1 305 | 306 | return (m) 307 | 308 | 309 | if __name__ == "__main__": 310 | 311 | client = setClient() 312 | 313 | prodList = modisClient(client) 314 | printList(prodList) 315 | 316 | bandList = modisClient(client, product='MOD15A2') 317 | printList(bandList) 318 | 319 | dateList = modisClient(client, 320 | product='MOD15A2', 321 | band='Lai_1km', 322 | lat=52, 323 | lon=0) 324 | printList(dateList) 325 | 326 | m = modisClient(client, 327 | product='MOD15A2', 328 | band='Lai_1km', 329 | lat=52, 330 | lon=-2, 331 | startDate=2006100, 332 | endDate=2006180) 333 | 334 | modisGetQA(m, 'FparLai_QC', client=client) 335 | 336 | m.applyScale() 337 | m.filterQA(range(0, 2 ** 16, 2), fill=-1) 338 | 339 | printModisData(m) 340 | -------------------------------------------------------------------------------- /bowshock/patents.py: -------------------------------------------------------------------------------- 1 | # The NASA patent portfolio is available to benefit US citizens. 2 | # Through partnerships and licensing agreements with industry, 3 | # these patents ensure that NASAs investments in pioneering research find secondary uses that benefit the economy 4 | # create jobs, and improve quality of life. This endpoint provides structured, searchable developer access to NASAs patents that have been curated to support technology transfer. 5 | from bowshock.helpers import nasa_api_key, bowshock_logger, dispatch_http_get 6 | 7 | logger = bowshock_logger() 8 | 9 | 10 | def patents(query=None, concept_tags=None, limit=None): 11 | ''' 12 | HTTP REQUEST 13 | 14 | GET https://api.nasa.gov/patents 15 | 16 | QUERY PARAMETERS 17 | 18 | Parameter Type Default Description 19 | query string None Search text to filter results 20 | concept_tags bool False Return an ordered dictionary of concepts from the patent abstract 21 | limit int all number of patents to return 22 | api_key string DEMO_KEY api.nasa.gov key for expanded usage 23 | EXAMPLE QUERY 24 | 25 | https://api.nasa.gov/patents/content?query=temperature&limit=5&api_key=DEMO_KEY 26 | 27 | ''' 28 | base_url = "https://api.nasa.gov/patents/content?" 29 | 30 | if not query: 31 | raise ValueError("search query is missing, which is mandatory.") 32 | elif not isinstance(query, str): 33 | try: 34 | query = str(query) 35 | except: 36 | raise ValueError("query has to be type of string") 37 | else: 38 | base_url += "query=" + query + "&" 39 | 40 | if concept_tags == True: 41 | base_url += "concept_tags=True" + "&" 42 | 43 | if limit: 44 | if not isinstance(limit, int): 45 | logger.error( 46 | "The limit arg you provided is not the type of int, ignoring it") 47 | 48 | base_url += "limit=" + str(limit) + "&" 49 | 50 | req_url = base_url + "api_key=" + nasa_api_key() 51 | 52 | return dispatch_http_get(req_url) 53 | -------------------------------------------------------------------------------- /bowshock/predictthesky.py: -------------------------------------------------------------------------------- 1 | # http://predictthesky.org/developers.html 2 | 3 | # Below description is taken from their website. 4 | # Introduction 5 | # It all starts with the root URL, the routes below are all based around this: 6 | 7 | # Retrieving Space Events 8 | # Events are the core purpose of the API. It returns a list of space objects (see below) which are visible from your current location, scored by a likelyhood that it can be seen. A weather object for the start and end of the event is returned. 9 | 10 | # Method Route Arguments 11 | # GET /events/all lat, lon, elevation, limit, date 12 | # GET /event/ lat, lon, elevation, limit, date 13 | import decimal 14 | 15 | from bowshock.helpers import bowshock_logger, validate_iso8601, validate_float, dispatch_http_get 16 | 17 | logger = bowshock_logger() 18 | 19 | 20 | def space_events(lon=None, lat=None, limit=None, date=None): 21 | ''' 22 | 23 | lat & lon expect decimal latitude and longitude values. (Required) 24 | elevation assumes meters. (Optional) 25 | limit assumes an integer. Default is 5. (Optional) 26 | date expects an ISO 8601 formatted date. (Optional) 27 | ''' 28 | 29 | base_url = 'http://api.predictthesky.org/?' 30 | 31 | if not lon or not lat: 32 | raise ValueError( 33 | "space_events endpoint expects lat and lon, type has to be float. Call the method with keyword args. Ex : lon=100.75, lat=1.5") 34 | else: 35 | try: 36 | validate_float(lon, lat) 37 | # Floats are entered/displayed as decimal numbers, but your computer 38 | # (in fact, your standard C library) stores them as binary. 39 | # You get some side effects from this transition: 40 | # >>> print len(repr(0.1)) 41 | # 19 42 | # >>> print repr(0.1) 43 | # 0.10000000000000001 44 | # Thus using decimal to str transition is more reliant 45 | lon = decimal.Decimal(lon) 46 | lat = decimal.Decimal(lat) 47 | base_url += "lon=" + str(lon) + "&" + "lat=" + str(lat) 48 | except: 49 | raise ValueError( 50 | "space_events endpoint expects lat and lon, type has to be float. Call the method with keyword args. Ex : lon=100.75, lat=1.5") 51 | 52 | if date: 53 | try: 54 | validate_iso8601(date) 55 | base_url += "&" + 'date=' + date 56 | except: 57 | raise ValueError( 58 | "Your date input is not in iso8601 format. ex: 2014-01-01T23:59:59") 59 | 60 | if limit: 61 | if not isinstance(limit, int): 62 | logger.error( 63 | "The limit arg you provided is not the type of int, ignoring it") 64 | base_url += "&" + "limit=" + str(limit) 65 | 66 | return dispatch_http_get(base_url) 67 | -------------------------------------------------------------------------------- /bowshock/skymorph.py: -------------------------------------------------------------------------------- 1 | # http://www.asterank.com/skymorph 2 | 3 | #This API wraps NASA's SkyMorph archive in a RESTful JSON interface. Currently, it provides observation and image data from the NEAT survey. 4 | from bowshock.helpers import bowshock_logger, dispatch_http_get 5 | 6 | logger = bowshock_logger() 7 | 8 | 9 | def search_target_obj(target): 10 | ''' 11 | Query for a specific target: 12 | 13 | http://asterank.com/api/skymorph/search? 14 | target Target object (lookup in MPC). 15 | ''' 16 | base_url = "http://asterank.com/api/skymorph/search?" 17 | 18 | if not isinstance(target, str): 19 | raise ValueError("The target arg you provided is not the type of str") 20 | else: 21 | base_url += "target=" + target 22 | 23 | return dispatch_http_get(base_url) 24 | 25 | 26 | def search_orbit(**kwargs): 27 | ''' 28 | Query based on orbital elements: 29 | 30 | http://asterank.com/api/skymorph/search_orbit? 31 | epoch Epoch ([M]JD or ISO) 32 | ecc eccentricity 33 | per Perihelion distance (AU) 34 | per_date Perihelion date ([M]JD or ISO) 35 | om Longitude of ascending node (deg) 36 | w Argument of perihelion (deg) 37 | i Inclination (deg) 38 | H Absolute magnitude 39 | 40 | ''' 41 | 42 | base_url = "http://asterank.com/api/skymorph/search_orbit?" 43 | 44 | for key in kwargs: 45 | base_url += str(key) + "=" + kwargs[key] + "&" 46 | 47 | # remove the unnecessary & at the end 48 | base_url = base_url[:-1] 49 | 50 | return dispatch_http_get(base_url) 51 | 52 | 53 | def search_position(**kwargs): 54 | ''' 55 | Query based on position and time (+/- 1 day): 56 | 57 | http://asterank.com/api/skymorph/search_position? 58 | ra Right ascension (HMS) 59 | Dec Declination (DMS) 60 | time Date and time (UTC) 61 | per_date Perihelion date ([M]JD or ISO) 62 | om Longitude of ascending node (deg) 63 | w Argument of perihelion (deg) 64 | i Inclination (deg) 65 | H Absolute magnitude 66 | 67 | ''' 68 | 69 | base_url = "http://asterank.com/api/skymorph/search_position?" 70 | 71 | for key in kwargs: 72 | base_url += str(key) + "=" + kwargs[key] + "&" 73 | 74 | # remove the unnecessary & at the end 75 | base_url = base_url[:-1] 76 | 77 | return dispatch_http_get(base_url) 78 | -------------------------------------------------------------------------------- /bowshock/star.py: -------------------------------------------------------------------------------- 1 | # http://hacktheuniverse.github.io/star-api/ 2 | 3 | from bowshock.helpers import dispatch_http_get 4 | 5 | 6 | def stars(): 7 | ''' 8 | This endpoint gets you a list of all stars in json 9 | ''' 10 | 11 | base_url = "http://star-api.herokuapp.com/api/v1/stars" 12 | 13 | return dispatch_http_get(base_url) 14 | 15 | 16 | def search_star(star): 17 | ''' 18 | It is also possible to query the stars by label, here is an example of querying for the star labeled as Sun. 19 | 20 | http://star-api.herokuapp.com/api/v1/stars/Sun 21 | ''' 22 | 23 | base_url = "http://star-api.herokuapp.com/api/v1/stars/" 24 | 25 | if not isinstance(star, str): 26 | raise ValueError("The star arg you provided is not the type of str") 27 | else: 28 | base_url += star 29 | 30 | return dispatch_http_get(base_url) 31 | 32 | 33 | def exoplanets(): 34 | ''' 35 | gets all exoplanets in json 36 | ''' 37 | 38 | base_url = "http://star-api.herokuapp.com/api/v1/exo_planets" 39 | 40 | return dispatch_http_get(base_url) 41 | 42 | 43 | def search_exoplanet(exoplanet): 44 | ''' 45 | It is also possible to query the exoplanets by label, here is an example of querying for the exoplanet labeled as 11 Com 46 | 47 | http://star-api.herokuapp.com/api/v1/exo_planets/11 Com 48 | ''' 49 | 50 | base_url = "http://star-api.herokuapp.com/api/v1/exo_planets/" 51 | 52 | if not isinstance(exoplanet, str): 53 | raise ValueError( 54 | "The exoplanet arg you provided is not the type of str") 55 | else: 56 | base_url += exoplanet 57 | 58 | return dispatch_http_get(base_url) 59 | 60 | 61 | def local_group_of_galaxies(): 62 | ''' 63 | gets a local group of galaxies in json 64 | ''' 65 | 66 | base_url = "http://star-api.herokuapp.com/api/v1/local_groups" 67 | 68 | return dispatch_http_get(base_url) 69 | 70 | 71 | def search_local_galaxies(galaxy): 72 | ''' 73 | It is also possible to query the local galaxies by label, here is an example of querying for the local galaxy labeled IC 10 74 | 75 | http://star-api.herokuapp.com/api/v1/local_groups/IC 10 76 | ''' 77 | 78 | base_url = "http://star-api.herokuapp.com/api/v1/local_groups/" 79 | 80 | if not isinstance(galaxy, str): 81 | raise ValueError("The galaxy arg you provided is not the type of str") 82 | else: 83 | base_url += galaxy 84 | 85 | return dispatch_http_get(base_url) 86 | 87 | 88 | def star_clusters(): 89 | ''' 90 | retrieves all open star clusters in json 91 | ''' 92 | 93 | base_url = "http://star-api.herokuapp.com/api/v1/open_cluster" 94 | 95 | return dispatch_http_get(base_url) 96 | 97 | 98 | def search_star_cluster(cluster): 99 | ''' 100 | It is also possible to query the star clusters by label, here is an example of querying for the star cluster labeled Berkeley 59 101 | 102 | http://star-api.herokuapp.com/api/v1/open_cluster/Berkeley 59 103 | ''' 104 | 105 | base_url = "http://star-api.herokuapp.com/api/v1/open_cluster/" 106 | 107 | if not isinstance(cluster, str): 108 | raise ValueError("The cluster arg you provided is not the type of str") 109 | else: 110 | base_url += cluster 111 | 112 | return dispatch_http_get(base_url) 113 | -------------------------------------------------------------------------------- /bowshock/techport.py: -------------------------------------------------------------------------------- 1 | # https://data.nasa.gov/developer/external/techport/techport-api.pdf 2 | 3 | #In May 2013, President Obama signed into law Executive Order 13642, Making Open and 4 | #Machine Readable the New Default for Government Information. This requirement promotes 5 | #continued job growth, government efficiency, and the social good that can be gained from 6 | #opening government data to the public. In order to facilitate the Open Data initiatives, 7 | #government information is managed as an asset throughout its life cycle to promote 8 | #interoperability and openness, and wherever possible and legally permissible, released to the 9 | #public in ways that make the data easy to find, accessible, and usable. 10 | #NASA is committed to making its data available and machine-readable through an Application 11 | #Programming Interface (API) to better serve its user communities. NASAs TechPort system 12 | #provides a RESTful web services API to make technology Program and Project data available in 13 | #a machine-readable format. This API can be used to export TechPort data into an XML format, 14 | #which can be further processed and analyzed. 15 | 16 | from bowshock.helpers import dispatch_http_get 17 | 18 | 19 | def techport(Id): 20 | ''' 21 | In order to use this capability, queries can be issued to the system with the following URI 22 | format: 23 | GET /xml-api/id_parameter 24 | Parameter Required? Value Description 25 | id_parameter Yes Type: String 26 | Default: None 27 | The id value of the TechPort record. 28 | TechPort values range from 0-20000. 29 | Not all values will yield results. Id 30 | values can be obtained through the 31 | standard TechPort search feature and 32 | are visible in the website URLs, e.g. 33 | http://techport.nasa.gov/view/0000, 34 | where 0000 is the id value. 35 | Example usage: 36 | http://techport.nasa.gov/xml-api/4795 37 | Output: The output of this query is an XML file with all field data of the TechPort record. 38 | ''' 39 | 40 | base_url = 'http://techport.nasa.gov/xml-api/' 41 | 42 | if not isinstance(Id, str): 43 | raise ValueError("The Id arg you provided is not the type of str") 44 | else: 45 | base_url += Id 46 | 47 | return dispatch_http_get(base_url) 48 | -------------------------------------------------------------------------------- /bowshock/temperature_anomalies.py: -------------------------------------------------------------------------------- 1 | # There is no doubt that, on average, the earth is warming. However, the warming is spatially heterogenous. 2 | # How much warmer (or cooler) is your hometown? This endpoint reports local temperature anomalies from the 3 | # Goddard Institute for Space Studies Surface Temperature Analysis via the New Scientist web application to explore global temperature anomalies. 4 | # This endpoint restructures the query and response to correspond to other APIs on api.nasa.gov. The developer supplies a location and date range, and the returned object is a list of dictionaries that is ready for visualization in the d3 framework. 5 | import decimal 6 | 7 | from bowshock.helpers import nasa_api_key, bowshock_logger, validate_year, validate_float, dispatch_http_get 8 | 9 | logger = bowshock_logger() 10 | 11 | 12 | def address(address=None, begin=None, end=None): 13 | ''' 14 | HTTP REQUEST 15 | 16 | GET https://api.nasa.gov/planetary/earth/temperature/address 17 | 18 | QUERY PARAMETERS 19 | 20 | Parameter Type Default Description 21 | text string n/a Address string 22 | begin int 1880 beginning year for date range, inclusive 23 | end int 2014 end year for date range, inclusive 24 | api_key string DEMO_KEY api.nasa.gov key for expanded usage 25 | EXAMPLE QUERY 26 | 27 | https://api.nasa.gov/planetary/earth/temperature/address?text=1800 F Street, NW, Washington DC&begin=1990 28 | ''' 29 | base_url = "https://api.nasa.gov/planetary/earth/temperature/address?" 30 | 31 | if not address: 32 | raise ValueError( 33 | "address is missing, which is mandatory. example : 1800 F Street, NW, Washington DC") 34 | elif not isinstance(address, str): 35 | try: 36 | address = str(address) 37 | except: 38 | raise ValueError("address has to be type of string") 39 | else: 40 | base_url += "text=" + address + "&" 41 | 42 | if not begin: 43 | raise ValueError( 44 | "Begin year is missing, which is mandatory. Format : YYYY") 45 | else: 46 | try: 47 | validate_year(begin) 48 | base_url += "begin=" + begin + "&" 49 | except: 50 | raise ValueError("Incorrect begin year format, should be YYYY") 51 | 52 | if end: 53 | try: 54 | validate_year(end) 55 | base_url += "end=" + end + "&" 56 | except: 57 | raise ValueError("Incorrect end year format, should be YYYY") 58 | 59 | req_url = base_url + "api_key=" + nasa_api_key() 60 | 61 | return dispatch_http_get(req_url) 62 | 63 | 64 | def coordinate(lon=None, lat=None, begin=None, end=None): 65 | ''' 66 | HTTP REQUEST 67 | 68 | GET https://api.nasa.gov/planetary/earth/temperature/coords 69 | 70 | QUERY PARAMETERS 71 | 72 | Parameter Type Default Description 73 | lat float n/a Latitude 74 | lon float n/a Longitude 75 | begin int 1880 beginning year for date range, inclusive 76 | end int 2014 end year for date range, inclusive 77 | api_key string DEMO_KEY api.nasa.gov key for expanded usage 78 | EXAMPLE QUERY 79 | 80 | https://api.nasa.gov/planetary/earth/temperature/coords?lon=100.3&lat=1.6&begin=1990&end=2005&api_key=DEMO_KEY 81 | 82 | 83 | ''' 84 | base_url = "https://api.nasa.gov/planetary/earth/temperature/coords?" 85 | 86 | if not lon or not lat: 87 | raise ValueError( 88 | "temp/coordinate endpoint expects lat and lon, type has to be float. Call the method with keyword args. Ex : lon=100.75, lat=1.5") 89 | else: 90 | try: 91 | validate_float(lon, lat) 92 | # Floats are entered/displayed as decimal numbers, but your computer 93 | # (in fact, your standard C library) stores them as binary. 94 | # You get some side effects from this transition: 95 | # >>> print len(repr(0.1)) 96 | # 19 97 | # >>> print repr(0.1) 98 | # 0.10000000000000001 99 | # Thus using decimal to str transition is more reliant 100 | lon = decimal.Decimal(lon) 101 | lat = decimal.Decimal(lat) 102 | base_url += "lon=" + str(lon) + "&" + "lat=" + str(lat) + "&" 103 | except: 104 | raise ValueError( 105 | "temp/coordinate endpoint expects lat and lon, type has to be float. Call the method with keyword args. Ex : lon=100.75, lat=1.5") 106 | 107 | if not begin: 108 | raise ValueError( 109 | "Begin year is missing, which is mandatory. Format : YYYY") 110 | else: 111 | try: 112 | validate_year(begin) 113 | base_url += "begin=" + begin + "&" 114 | except: 115 | raise ValueError("Incorrect begin year format, should be YYYY") 116 | 117 | if end: 118 | try: 119 | validate_year(end) 120 | base_url += "end=" + end + "&" 121 | except: 122 | raise ValueError("Incorrect end year format, should be YYYY") 123 | req_url = base_url + "api_key=" + nasa_api_key() 124 | 125 | return dispatch_http_get(req_url) 126 | -------------------------------------------------------------------------------- /docs/bowshock.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emirozer/bowshock/9f5e053f1d54995b833b83616f37c67178c3e840/docs/bowshock.jpg -------------------------------------------------------------------------------- /docs/bowshock2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emirozer/bowshock/9f5e053f1d54995b833b83616f37c67178c3e840/docs/bowshock2.png -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | --index-url https://pypi.python.org/simple/ 2 | 3 | -e . 4 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | import os 3 | 4 | setup( 5 | name='bowshock', 6 | version='0.0.2', 7 | author='Emir Ozer', 8 | author_email='emirozer@yandex.com', 9 | url='https://github.com/emirozer/bowshock', 10 | description='An all-in-one library for NASA API\'s', 11 | long_description=os.path.join(os.path.dirname(__file__), 'README.md'), 12 | packages=find_packages(exclude=[]), 13 | install_requires=[ 14 | 'requests>=2.6.1', 15 | ], 16 | include_package_data=True, 17 | classifiers=[ 18 | 'Development Status :: 4 - Beta', 19 | 'Environment :: Console', 20 | 'Intended Audience :: Developers', 21 | 'Operating System :: OS Independent', 22 | 'Programming Language :: Python', 23 | ], 24 | keywords='nasa api wrapper', 25 | ) 26 | -------------------------------------------------------------------------------- /tests/test_apod.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import sys 3 | from time import sleep 4 | 5 | sys.path.append("../bowshock/") 6 | 7 | from bowshock import apod 8 | 9 | 10 | class apod_UnitTests(unittest.TestCase): 11 | def test_apod_endpoint_full(self): 12 | 13 | r = apod.apod(date="2015-02-02", concept_tags=True) 14 | self.assertEqual(r.status_code, 200) 15 | sleep(2) 16 | 17 | def test_apod_endpoint_notags(self): 18 | 19 | r = apod.apod(date="2015-02-02") 20 | self.assertEqual(r.status_code, 200) 21 | sleep(2) 22 | 23 | def test_apod_endpoint_noargs(self): 24 | # no tags should pass , as no date defaults to today 25 | r = apod.apod() 26 | self.assertEqual(r.status_code, 200) 27 | sleep(2) 28 | 29 | 30 | if __name__ == "__main__": 31 | 32 | # Build the test suite 33 | suite = unittest.TestSuite() 34 | suite.addTest(unittest.makeSuite(apod_UnitTests)) 35 | 36 | # Execute the test suite 37 | result = unittest.TextTestRunner(verbosity=2).run(suite) 38 | sys.exit(len(result.errors) + len(result.failures)) 39 | -------------------------------------------------------------------------------- /tests/test_asterank.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import sys 3 | from time import sleep 4 | 5 | sys.path.append("../bowshock/") 6 | 7 | from bowshock import asterank 8 | 9 | class asterank_UnitTests(unittest.TestCase): 10 | def test_asterank_api_full(self): 11 | 12 | r = asterank.asterank( 13 | query={"e": {"$lt": 0.1}, 14 | "i": {"$lt": 4}, 15 | "a": {"$lt": 1.5}}, 16 | limit=1) 17 | self.assertEqual(r.status_code, 200) 18 | sleep(2) 19 | 20 | 21 | if __name__ == "__main__": 22 | 23 | # Build the test suite 24 | suite = unittest.TestSuite() 25 | suite.addTest(unittest.makeSuite(asterank_UnitTests)) 26 | 27 | # Execute the test suite 28 | result = unittest.TextTestRunner(verbosity=2).run(suite) 29 | sys.exit(len(result.errors) + len(result.failures)) 30 | -------------------------------------------------------------------------------- /tests/test_earth.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import sys 3 | from time import sleep 4 | 5 | sys.path.append("../bowshock/") 6 | 7 | from bowshock import earth 8 | 9 | 10 | class earth_UnitTests(unittest.TestCase): 11 | def test_imagery_endpoint_full(self): 12 | 13 | r = earth.imagery(lon=100.75, 14 | lat=1.6, 15 | dim=0.0025, 16 | date="2015-02-02", 17 | cloud_score=True) 18 | self.assertEqual(r.status_code, 200) 19 | sleep(2) 20 | 21 | def test_imagery_endpoint_nodim(self): 22 | 23 | r = earth.imagery(lon=100.75, lat=1.6, date="2015-02-02", cloud_score=True) 24 | self.assertEqual(r.status_code, 200) 25 | sleep(2) 26 | 27 | def test_imagery_endpoint_nocloudscore(self): 28 | 29 | r = earth.imagery(lon=100.75, lat=1.6, date="2015-02-02") 30 | self.assertEqual(r.status_code, 200) 31 | sleep(2) 32 | 33 | def test_imagery_endpoint_nodate(self): 34 | 35 | r = earth.imagery(lon=100.75, lat=1.6) 36 | self.assertEqual(r.status_code, 200) 37 | sleep(2) 38 | 39 | def test_assets_endpoint_noenddate(self): 40 | 41 | r = earth.assets(lon=100.75, lat=1.6, begin="2015-02-02") 42 | self.assertEqual(r.status_code, 200) 43 | sleep(2) 44 | 45 | def test_assets_endpoint_full(self): 46 | 47 | r = earth.assets(lon=100.75, lat=1.6, begin="2015-02-02", end="2015-02-10") 48 | self.assertEqual(r.status_code, 200) 49 | sleep(2) 50 | 51 | 52 | if __name__ == "__main__": 53 | 54 | # Build the test suite 55 | suite = unittest.TestSuite() 56 | suite.addTest(unittest.makeSuite(earth_UnitTests)) 57 | 58 | # Execute the test suite 59 | result = unittest.TextTestRunner(verbosity=2).run(suite) 60 | sys.exit(len(result.errors) + len(result.failures)) 61 | -------------------------------------------------------------------------------- /tests/test_helioviewer.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import sys 3 | from time import sleep 4 | 5 | sys.path.append("../bowshock/") 6 | 7 | from bowshock import helioviewer 8 | 9 | 10 | class helioviewer_UnitTests(unittest.TestCase): 11 | def test_helioviewer_api_getjp2image(self): 12 | 13 | r = helioviewer.getjp2image(date='2014-01-01T23:59:59', sourceId=14) 14 | self.assertEqual(r.status_code, 200) 15 | sleep(2) 16 | 17 | def test_helioviewer_api_getjp2header(self): 18 | 19 | r = helioviewer.getjp2header(Id=7654321) 20 | self.assertEqual(r.status_code, 200) 21 | sleep(2) 22 | 23 | 24 | if __name__ == "__main__": 25 | 26 | # Build the test suite 27 | suite = unittest.TestSuite() 28 | suite.addTest(unittest.makeSuite(helioviewer_UnitTests)) 29 | 30 | # Execute the test suite 31 | result = unittest.TextTestRunner(verbosity=2).run(suite) 32 | sys.exit(len(result.errors) + len(result.failures)) 33 | -------------------------------------------------------------------------------- /tests/test_maas.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import sys 3 | from time import sleep 4 | 5 | sys.path.append("../bowshock/") 6 | 7 | from bowshock import maas 8 | 9 | class maas_UnitTests(unittest.TestCase): 10 | def test_maas_latest_endpoint(self): 11 | 12 | r = maas.maas_latest() 13 | self.assertEqual(r.status_code, 200) 14 | sleep(2) 15 | 16 | def test_maas_archive_endpoint_w_dates(self): 17 | 18 | r = maas.maas_archive('2012-10-01', '2012-10-31') 19 | self.assertEqual(r.status_code, 200) 20 | sleep(2) 21 | 22 | 23 | if __name__ == "__main__": 24 | # Build the test suite 25 | suite = unittest.TestSuite() 26 | suite.addTest(unittest.makeSuite(maas_UnitTests)) 27 | 28 | # Execute the test suite 29 | result = unittest.TextTestRunner(verbosity=2).run(suite) 30 | sys.exit(len(result.errors) + len(result.failures)) 31 | -------------------------------------------------------------------------------- /tests/test_patents.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import sys 3 | from time import sleep 4 | 5 | sys.path.append("../bowshock/") 6 | 7 | from bowshock import patents 8 | 9 | class patents_UnitTests(unittest.TestCase): 10 | def test_patents_endpoint_full(self): 11 | 12 | r = patents.patents(query="temperature", concept_tags=True, limit=5) 13 | self.assertEqual(r.status_code, 200) 14 | sleep(2) 15 | 16 | def test_patents_endpoint_notags(self): 17 | 18 | r = patents.patents(query="temperature", limit=5) 19 | self.assertEqual(r.status_code, 200) 20 | sleep(2) 21 | 22 | def test_patents_endpoint_nolimit(self): 23 | 24 | r = patents.patents(query="temperature") 25 | self.assertEqual(r.status_code, 200) 26 | sleep(2) 27 | 28 | 29 | if __name__ == "__main__": 30 | 31 | # Build the test suite 32 | suite = unittest.TestSuite() 33 | suite.addTest(unittest.makeSuite(patents_UnitTests)) 34 | 35 | # Execute the test suite 36 | result = unittest.TextTestRunner(verbosity=2).run(suite) 37 | sys.exit(len(result.errors) + len(result.failures)) 38 | -------------------------------------------------------------------------------- /tests/test_predictthesky.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import sys 3 | from time import sleep 4 | 5 | sys.path.append("../bowshock/") 6 | 7 | from bowshock import predictthesky 8 | 9 | @unittest.skip("Predictthesky.org API still in development") 10 | class predictthesky_UnitTests(unittest.TestCase): 11 | def test_spaceevents_endpoint_latlon(self): 12 | 13 | r = predictthesky.space_events(lon=100.75, lat=1.5) 14 | self.assertEqual(r.status_code, 200) 15 | sleep(2) 16 | 17 | 18 | if __name__ == "__main__": 19 | 20 | # Build the test suite 21 | suite = unittest.TestSuite() 22 | suite.addTest(unittest.makeSuite(predictthesky_UnitTests)) 23 | 24 | # Execute the test suite 25 | result = unittest.TextTestRunner(verbosity=2).run(suite) 26 | sys.exit(len(result.errors) + len(result.failures)) 27 | -------------------------------------------------------------------------------- /tests/test_skymorph.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import sys 3 | from time import sleep 4 | 5 | sys.path.append("../bowshock/") 6 | 7 | from bowshock import skymorph 8 | 9 | class skymorph_UnitTests(unittest.TestCase): 10 | def test_skymorph_object_search(self): 11 | 12 | r = skymorph.search_target_obj("J99TS7A") 13 | self.assertEqual(r.status_code, 200) 14 | sleep(2) 15 | 16 | 17 | if __name__ == "__main__": 18 | # Build the test suite 19 | suite = unittest.TestSuite() 20 | suite.addTest(unittest.makeSuite(skymorph_UnitTests)) 21 | 22 | # Execute the test suite 23 | result = unittest.TextTestRunner(verbosity=2).run(suite) 24 | sys.exit(len(result.errors) + len(result.failures)) 25 | -------------------------------------------------------------------------------- /tests/test_star.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import sys 3 | 4 | sys.path.append("../bowshock/") 5 | 6 | from time import sleep 7 | from bowshock import star 8 | 9 | 10 | class star_UnitTests(unittest.TestCase): 11 | def test_stars(self): 12 | 13 | r = star.stars() 14 | self.assertEqual(r.status_code, 200) 15 | sleep(2) 16 | 17 | def test_search_star(self): 18 | 19 | r = star.search_star("Sun") 20 | self.assertEqual(r.status_code, 200) 21 | sleep(2) 22 | 23 | def test_exoplanets(self): 24 | 25 | r = star.exoplanets() 26 | self.assertEqual(r.status_code, 200) 27 | sleep(2) 28 | 29 | def test_search_exoplanet(self): 30 | 31 | r = star.search_exoplanet("11 Com") 32 | self.assertEqual(r.status_code, 200) 33 | sleep(2) 34 | 35 | def test_local_group_of_galaxies(self): 36 | 37 | r = star.local_group_of_galaxies() 38 | self.assertEqual(r.status_code, 200) 39 | sleep(2) 40 | 41 | def test_search_local_galaxies(self): 42 | 43 | r = star.search_local_galaxies("IC 10") 44 | self.assertEqual(r.status_code, 200) 45 | sleep(2) 46 | 47 | def test_star_clusters(self): 48 | 49 | r = star.star_clusters() 50 | self.assertEqual(r.status_code, 200) 51 | sleep(2) 52 | 53 | def test_search_star_clusters(self): 54 | 55 | r = star.search_star_cluster("Berkeley 59") 56 | self.assertEqual(r.status_code, 200) 57 | sleep(2) 58 | 59 | 60 | if __name__ == "__main__": 61 | 62 | # Build the test suite 63 | suite = unittest.TestSuite() 64 | suite.addTest(unittest.makeSuite(star_UnitTests)) 65 | 66 | # Execute the test suite 67 | result = unittest.TextTestRunner(verbosity=2).run(suite) 68 | sys.exit(len(result.errors) + len(result.failures)) 69 | -------------------------------------------------------------------------------- /tests/test_techport.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import sys 3 | from time import sleep 4 | 5 | sys.path.append("../bowshock/") 6 | 7 | from bowshock import techport 8 | 9 | class techport_UnitTests(unittest.TestCase): 10 | def test_techport_api(self): 11 | 12 | r = techport.techport(Id="4795") 13 | self.assertEqual(r.status_code, 200) 14 | sleep(2) 15 | 16 | 17 | if __name__ == "__main__": 18 | 19 | # Build the test suite 20 | suite = unittest.TestSuite() 21 | suite.addTest(unittest.makeSuite(techport_UnitTests)) 22 | 23 | # Execute the test suite 24 | result = unittest.TextTestRunner(verbosity=2).run(suite) 25 | sys.exit(len(result.errors) + len(result.failures)) 26 | -------------------------------------------------------------------------------- /tests/test_temperature_anomalies.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import sys 3 | from time import sleep 4 | 5 | sys.path.append("../bowshock/") 6 | 7 | from bowshock import temperature_anomalies 8 | 9 | 10 | class temperatureAnomalies_UnitTests(unittest.TestCase): 11 | 12 | # ENDPOINTS NOT WORKING 13 | #def test_ta_adress_endpoint_noend(self): 14 | # 15 | # r = adress(adress='1800 F Street, NW, Washington DC', begin="1990") 16 | # self.assertEqual(r.status_code, 200) 17 | # sleep(2) 18 | 19 | #def test_ta_adress_endpoint_full(self): 20 | # 21 | # r = adress(adress='1800 F Street, NW, Washington DC', begin="1990", end="2000") 22 | # self.assertEqual(r.status_code, 200) 23 | # sleep(2) 24 | 25 | def test_ta_coordinate_endpoint_noend(self): 26 | 27 | r = temperature_anomalies.coordinate(lon=100.3, lat=1.6, begin="1990") 28 | self.assertEqual(r.status_code, 200) 29 | sleep(2) 30 | 31 | def test_ta_coordinate_endpoint_full(self): 32 | 33 | r = temperature_anomalies.coordinate(lon=100.3, lat=1.6, begin="1990", end="2005") 34 | self.assertEqual(r.status_code, 200) 35 | sleep(2) 36 | 37 | 38 | if __name__ == "__main__": 39 | # Build the test suite 40 | suite = unittest.TestSuite() 41 | suite.addTest(unittest.makeSuite(temperatureAnomalies_UnitTests)) 42 | 43 | # Execute the test suite 44 | result = unittest.TextTestRunner(verbosity=2).run(suite) 45 | sys.exit(len(result.errors) + len(result.failures)) 46 | --------------------------------------------------------------------------------