PyMMT 1.0.0__tar.gz → 1.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {PyMMT-1.0.0 → pymmt-1.0.2}/PKG-INFO +45 -17
- {PyMMT-1.0.0 → pymmt-1.0.2}/README.md +40 -15
- {PyMMT-1.0.0 → pymmt-1.0.2}/pyproject.toml +1 -1
- {PyMMT-1.0.0 → pymmt-1.0.2}/src/PyMMT.egg-info/PKG-INFO +45 -17
- {PyMMT-1.0.0 → pymmt-1.0.2}/src/PyMMT.egg-info/SOURCES.txt +1 -2
- {PyMMT-1.0.0 → pymmt-1.0.2}/src/pymmt/pymmt.py +23 -17
- PyMMT-1.0.0/tests/test.py +0 -33
- {PyMMT-1.0.0 → pymmt-1.0.2}/setup.cfg +0 -0
- {PyMMT-1.0.0 → pymmt-1.0.2}/src/PyMMT.egg-info/dependency_links.txt +0 -0
- {PyMMT-1.0.0 → pymmt-1.0.2}/src/PyMMT.egg-info/requires.txt +0 -0
- {PyMMT-1.0.0 → pymmt-1.0.2}/src/PyMMT.egg-info/top_level.txt +0 -0
- {PyMMT-1.0.0 → pymmt-1.0.2}/src/pymmt/__init__.py +0 -0
- {PyMMT-1.0.0 → pymmt-1.0.2}/src/pymmt/instruments/__init__.py +0 -0
- {PyMMT-1.0.0 → pymmt-1.0.2}/src/pymmt/instruments/binospec.py +0 -0
- {PyMMT-1.0.0 → pymmt-1.0.2}/src/pymmt/instruments/mmirs.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: PyMMT
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.2
|
|
4
4
|
Summary: A python API wrapper for the MMT Observatory
|
|
5
5
|
Author-email: Samuel Wyatt <swyatt@arizona.edu>, Manisha Shrestha <mshrestha1@arizona.edu>, Griffin Hosseinzadeh <griffin0@arizona.edu>
|
|
6
6
|
Project-URL: Homepage, https://github.com/SAGUARO-MMA/PyMMT
|
|
@@ -10,17 +10,22 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
11
11
|
Requires-Python: >=3.10
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: requests
|
|
14
|
+
Requires-Dist: setuptools_scm
|
|
15
|
+
Requires-Dist: ipykernel
|
|
13
16
|
|
|
17
|
+
[](https://doi.org/10.5281/zenodo.8322354)
|
|
14
18
|
# PyMMT
|
|
15
19
|
|
|
16
|
-
This repository is designed to facilitate
|
|
20
|
+
This repository is designed to facilitate rapid Target of Opportunity (ToO) observations to Binospec or MMIRS at the [MMT](https://www.mmto.org/) to enable same-night spectroscopy of interesting transients. Here we will provide examples to install and upload targets.
|
|
17
21
|
|
|
18
22
|
## Install
|
|
19
23
|
To get the repository (in a bash/unix terminal)
|
|
20
24
|
```bash
|
|
21
25
|
git-clone repository
|
|
26
|
+
python -m pip install -e .
|
|
27
|
+
#or
|
|
22
28
|
python -m pip install pymmt
|
|
23
|
-
or pip install pymmt
|
|
24
29
|
```
|
|
25
30
|
|
|
26
31
|
## Using the API Wrapper
|
|
@@ -83,12 +88,18 @@ For Binospec `observationtype:longslit`:
|
|
|
83
88
|
* For `Longslit1_25`: id `131`
|
|
84
89
|
* For `Longslit1_5`: id `114`
|
|
85
90
|
* For `Longslit5`: id `112`
|
|
91
|
+
* `exposuretime`: The observation exposure time in seconds
|
|
86
92
|
|
|
87
93
|
For MMIRS `observationtype:longslit`:
|
|
88
94
|
* `grism`: Valid options are `J`, `HK`, and `HK3`
|
|
95
|
+
* `filter`: valid options are `Y`, `J`, `H`, `Ks`, `zJ`, `HK`, `HK3`, `Kspec`
|
|
89
96
|
* `readtab`: Valid options are `ramp_4.426`
|
|
90
|
-
* `slitwidth`: valid options are
|
|
97
|
+
* `slitwidth`: valid options are `1pixel`, `2pixel`, `3pixel`, `4pixel`, `5pixel`, `6pixel`, `12pixel`
|
|
91
98
|
* `slitwidthproperty`: valid options are 'long', 'short'
|
|
99
|
+
* `maskid`: Can be a predefined machined mask, or a preset for imaging or spectroscopy:
|
|
100
|
+
* For imaging: id `110`
|
|
101
|
+
* For spectroscopy: id `111`
|
|
102
|
+
* `exposuretime`: The observation exposure time in seconds
|
|
92
103
|
|
|
93
104
|
Other observation metadata:
|
|
94
105
|
|
|
@@ -106,7 +117,6 @@ All metadata will be validated upon initialization. Once the target object has b
|
|
|
106
117
|
import pymmt
|
|
107
118
|
|
|
108
119
|
#example for Binospec imaging target payload:
|
|
109
|
-
|
|
110
120
|
payload = {
|
|
111
121
|
'objectid':'TARGETNAME',
|
|
112
122
|
'ra':'12:34:56.78',
|
|
@@ -123,7 +133,6 @@ payload = {
|
|
|
123
133
|
|
|
124
134
|
|
|
125
135
|
#example payload for Binospec longslit target payload
|
|
126
|
-
|
|
127
136
|
payload = {
|
|
128
137
|
'objectid':'Targetname',
|
|
129
138
|
'ra':'12:34:56.78',
|
|
@@ -136,17 +145,36 @@ payload = {
|
|
|
136
145
|
`maskid`:131,
|
|
137
146
|
`filter`:'LP380'
|
|
138
147
|
'visits':1,
|
|
148
|
+
'exposuretime':900,
|
|
139
149
|
'numberexposures':2,
|
|
140
150
|
'priority':1,
|
|
141
151
|
'targetofopportunity':1
|
|
142
152
|
}
|
|
143
|
-
#example payload for MMIRS longslit target payload
|
|
144
153
|
|
|
145
|
-
payload
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
154
|
+
#example payload for MMIRS longslit target payload
|
|
155
|
+
payload = {
|
|
156
|
+
'objectid': 'AT2021fxy',
|
|
157
|
+
'ra': '13:13:01.560',
|
|
158
|
+
'dec': '-19:30:45.100',
|
|
159
|
+
'epoch': 'J2000',
|
|
160
|
+
'exposuretime': 450.0,
|
|
161
|
+
'filter': 'zJ',
|
|
162
|
+
'grism': 'J',
|
|
163
|
+
'magnitude': 16.9,
|
|
164
|
+
'maskid': 111,
|
|
165
|
+
'notes': 'Demo observation request. Please do not observe this.',
|
|
166
|
+
'numberexposures': 3,
|
|
167
|
+
'observationtype': 'longslit',
|
|
168
|
+
'priority': 3,
|
|
169
|
+
'slitwidth': '1pixel',
|
|
170
|
+
'targetofopportunity': 0,
|
|
171
|
+
'visits': 1,
|
|
172
|
+
'instrumentid':15,
|
|
173
|
+
'gain':'low',
|
|
174
|
+
'readtab': 'ramp_4.426',
|
|
175
|
+
'slitwidthproperty':'long',
|
|
176
|
+
'dithersize':'5'
|
|
177
|
+
}
|
|
150
178
|
|
|
151
179
|
#this will create the target along with validating the payload information. It will inform the user of any errors or warnings associated with the metadata
|
|
152
180
|
target = pymmt.Target(token=API_TOKEN,
|
|
@@ -235,14 +263,14 @@ if you don't pass any params into the function it will just find the current ins
|
|
|
235
263
|
|
|
236
264
|
```python
|
|
237
265
|
from datetime import datetime, timedelta
|
|
238
|
-
|
|
239
|
-
current_instruments =
|
|
266
|
+
insts = pymmt.Instruments()
|
|
267
|
+
current_instruments = insts.get_instruments()
|
|
240
268
|
|
|
241
269
|
#you can look into the future to see what instruments will be available:
|
|
242
|
-
future_instruments =
|
|
270
|
+
future_instruments = insts.get_instruments(date=datetime.datetime.now()+timedelta(months=1))
|
|
243
271
|
|
|
244
272
|
#you can look through the entire published schedule to see when a certain instrument will be on the telescope (Binospec = 16, MMIRS = 15)
|
|
245
|
-
my_instrument =
|
|
273
|
+
my_instrument = insts.get_instruments(instrumentid=16)
|
|
246
274
|
```
|
|
247
275
|
|
|
248
276
|
This function returns a list of dictionary elements with the values for:
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
[](https://doi.org/10.5281/zenodo.8322354)
|
|
1
2
|
# PyMMT
|
|
2
3
|
|
|
3
|
-
This repository is designed to facilitate
|
|
4
|
+
This repository is designed to facilitate rapid Target of Opportunity (ToO) observations to Binospec or MMIRS at the [MMT](https://www.mmto.org/) to enable same-night spectroscopy of interesting transients. Here we will provide examples to install and upload targets.
|
|
4
5
|
|
|
5
6
|
## Install
|
|
6
7
|
To get the repository (in a bash/unix terminal)
|
|
7
8
|
```bash
|
|
8
9
|
git-clone repository
|
|
10
|
+
python -m pip install -e .
|
|
11
|
+
#or
|
|
9
12
|
python -m pip install pymmt
|
|
10
|
-
or pip install pymmt
|
|
11
13
|
```
|
|
12
14
|
|
|
13
15
|
## Using the API Wrapper
|
|
@@ -70,12 +72,18 @@ For Binospec `observationtype:longslit`:
|
|
|
70
72
|
* For `Longslit1_25`: id `131`
|
|
71
73
|
* For `Longslit1_5`: id `114`
|
|
72
74
|
* For `Longslit5`: id `112`
|
|
75
|
+
* `exposuretime`: The observation exposure time in seconds
|
|
73
76
|
|
|
74
77
|
For MMIRS `observationtype:longslit`:
|
|
75
78
|
* `grism`: Valid options are `J`, `HK`, and `HK3`
|
|
79
|
+
* `filter`: valid options are `Y`, `J`, `H`, `Ks`, `zJ`, `HK`, `HK3`, `Kspec`
|
|
76
80
|
* `readtab`: Valid options are `ramp_4.426`
|
|
77
|
-
* `slitwidth`: valid options are
|
|
81
|
+
* `slitwidth`: valid options are `1pixel`, `2pixel`, `3pixel`, `4pixel`, `5pixel`, `6pixel`, `12pixel`
|
|
78
82
|
* `slitwidthproperty`: valid options are 'long', 'short'
|
|
83
|
+
* `maskid`: Can be a predefined machined mask, or a preset for imaging or spectroscopy:
|
|
84
|
+
* For imaging: id `110`
|
|
85
|
+
* For spectroscopy: id `111`
|
|
86
|
+
* `exposuretime`: The observation exposure time in seconds
|
|
79
87
|
|
|
80
88
|
Other observation metadata:
|
|
81
89
|
|
|
@@ -93,7 +101,6 @@ All metadata will be validated upon initialization. Once the target object has b
|
|
|
93
101
|
import pymmt
|
|
94
102
|
|
|
95
103
|
#example for Binospec imaging target payload:
|
|
96
|
-
|
|
97
104
|
payload = {
|
|
98
105
|
'objectid':'TARGETNAME',
|
|
99
106
|
'ra':'12:34:56.78',
|
|
@@ -110,7 +117,6 @@ payload = {
|
|
|
110
117
|
|
|
111
118
|
|
|
112
119
|
#example payload for Binospec longslit target payload
|
|
113
|
-
|
|
114
120
|
payload = {
|
|
115
121
|
'objectid':'Targetname',
|
|
116
122
|
'ra':'12:34:56.78',
|
|
@@ -123,17 +129,36 @@ payload = {
|
|
|
123
129
|
`maskid`:131,
|
|
124
130
|
`filter`:'LP380'
|
|
125
131
|
'visits':1,
|
|
132
|
+
'exposuretime':900,
|
|
126
133
|
'numberexposures':2,
|
|
127
134
|
'priority':1,
|
|
128
135
|
'targetofopportunity':1
|
|
129
136
|
}
|
|
130
|
-
#example payload for MMIRS longslit target payload
|
|
131
137
|
|
|
132
|
-
payload
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
138
|
+
#example payload for MMIRS longslit target payload
|
|
139
|
+
payload = {
|
|
140
|
+
'objectid': 'AT2021fxy',
|
|
141
|
+
'ra': '13:13:01.560',
|
|
142
|
+
'dec': '-19:30:45.100',
|
|
143
|
+
'epoch': 'J2000',
|
|
144
|
+
'exposuretime': 450.0,
|
|
145
|
+
'filter': 'zJ',
|
|
146
|
+
'grism': 'J',
|
|
147
|
+
'magnitude': 16.9,
|
|
148
|
+
'maskid': 111,
|
|
149
|
+
'notes': 'Demo observation request. Please do not observe this.',
|
|
150
|
+
'numberexposures': 3,
|
|
151
|
+
'observationtype': 'longslit',
|
|
152
|
+
'priority': 3,
|
|
153
|
+
'slitwidth': '1pixel',
|
|
154
|
+
'targetofopportunity': 0,
|
|
155
|
+
'visits': 1,
|
|
156
|
+
'instrumentid':15,
|
|
157
|
+
'gain':'low',
|
|
158
|
+
'readtab': 'ramp_4.426',
|
|
159
|
+
'slitwidthproperty':'long',
|
|
160
|
+
'dithersize':'5'
|
|
161
|
+
}
|
|
137
162
|
|
|
138
163
|
#this will create the target along with validating the payload information. It will inform the user of any errors or warnings associated with the metadata
|
|
139
164
|
target = pymmt.Target(token=API_TOKEN,
|
|
@@ -222,14 +247,14 @@ if you don't pass any params into the function it will just find the current ins
|
|
|
222
247
|
|
|
223
248
|
```python
|
|
224
249
|
from datetime import datetime, timedelta
|
|
225
|
-
|
|
226
|
-
current_instruments =
|
|
250
|
+
insts = pymmt.Instruments()
|
|
251
|
+
current_instruments = insts.get_instruments()
|
|
227
252
|
|
|
228
253
|
#you can look into the future to see what instruments will be available:
|
|
229
|
-
future_instruments =
|
|
254
|
+
future_instruments = insts.get_instruments(date=datetime.datetime.now()+timedelta(months=1))
|
|
230
255
|
|
|
231
256
|
#you can look through the entire published schedule to see when a certain instrument will be on the telescope (Binospec = 16, MMIRS = 15)
|
|
232
|
-
my_instrument =
|
|
257
|
+
my_instrument = insts.get_instruments(instrumentid=16)
|
|
233
258
|
```
|
|
234
259
|
|
|
235
260
|
This function returns a list of dictionary elements with the values for:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: PyMMT
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.2
|
|
4
4
|
Summary: A python API wrapper for the MMT Observatory
|
|
5
5
|
Author-email: Samuel Wyatt <swyatt@arizona.edu>, Manisha Shrestha <mshrestha1@arizona.edu>, Griffin Hosseinzadeh <griffin0@arizona.edu>
|
|
6
6
|
Project-URL: Homepage, https://github.com/SAGUARO-MMA/PyMMT
|
|
@@ -10,17 +10,22 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
11
11
|
Requires-Python: >=3.10
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: requests
|
|
14
|
+
Requires-Dist: setuptools_scm
|
|
15
|
+
Requires-Dist: ipykernel
|
|
13
16
|
|
|
17
|
+
[](https://doi.org/10.5281/zenodo.8322354)
|
|
14
18
|
# PyMMT
|
|
15
19
|
|
|
16
|
-
This repository is designed to facilitate
|
|
20
|
+
This repository is designed to facilitate rapid Target of Opportunity (ToO) observations to Binospec or MMIRS at the [MMT](https://www.mmto.org/) to enable same-night spectroscopy of interesting transients. Here we will provide examples to install and upload targets.
|
|
17
21
|
|
|
18
22
|
## Install
|
|
19
23
|
To get the repository (in a bash/unix terminal)
|
|
20
24
|
```bash
|
|
21
25
|
git-clone repository
|
|
26
|
+
python -m pip install -e .
|
|
27
|
+
#or
|
|
22
28
|
python -m pip install pymmt
|
|
23
|
-
or pip install pymmt
|
|
24
29
|
```
|
|
25
30
|
|
|
26
31
|
## Using the API Wrapper
|
|
@@ -83,12 +88,18 @@ For Binospec `observationtype:longslit`:
|
|
|
83
88
|
* For `Longslit1_25`: id `131`
|
|
84
89
|
* For `Longslit1_5`: id `114`
|
|
85
90
|
* For `Longslit5`: id `112`
|
|
91
|
+
* `exposuretime`: The observation exposure time in seconds
|
|
86
92
|
|
|
87
93
|
For MMIRS `observationtype:longslit`:
|
|
88
94
|
* `grism`: Valid options are `J`, `HK`, and `HK3`
|
|
95
|
+
* `filter`: valid options are `Y`, `J`, `H`, `Ks`, `zJ`, `HK`, `HK3`, `Kspec`
|
|
89
96
|
* `readtab`: Valid options are `ramp_4.426`
|
|
90
|
-
* `slitwidth`: valid options are
|
|
97
|
+
* `slitwidth`: valid options are `1pixel`, `2pixel`, `3pixel`, `4pixel`, `5pixel`, `6pixel`, `12pixel`
|
|
91
98
|
* `slitwidthproperty`: valid options are 'long', 'short'
|
|
99
|
+
* `maskid`: Can be a predefined machined mask, or a preset for imaging or spectroscopy:
|
|
100
|
+
* For imaging: id `110`
|
|
101
|
+
* For spectroscopy: id `111`
|
|
102
|
+
* `exposuretime`: The observation exposure time in seconds
|
|
92
103
|
|
|
93
104
|
Other observation metadata:
|
|
94
105
|
|
|
@@ -106,7 +117,6 @@ All metadata will be validated upon initialization. Once the target object has b
|
|
|
106
117
|
import pymmt
|
|
107
118
|
|
|
108
119
|
#example for Binospec imaging target payload:
|
|
109
|
-
|
|
110
120
|
payload = {
|
|
111
121
|
'objectid':'TARGETNAME',
|
|
112
122
|
'ra':'12:34:56.78',
|
|
@@ -123,7 +133,6 @@ payload = {
|
|
|
123
133
|
|
|
124
134
|
|
|
125
135
|
#example payload for Binospec longslit target payload
|
|
126
|
-
|
|
127
136
|
payload = {
|
|
128
137
|
'objectid':'Targetname',
|
|
129
138
|
'ra':'12:34:56.78',
|
|
@@ -136,17 +145,36 @@ payload = {
|
|
|
136
145
|
`maskid`:131,
|
|
137
146
|
`filter`:'LP380'
|
|
138
147
|
'visits':1,
|
|
148
|
+
'exposuretime':900,
|
|
139
149
|
'numberexposures':2,
|
|
140
150
|
'priority':1,
|
|
141
151
|
'targetofopportunity':1
|
|
142
152
|
}
|
|
143
|
-
#example payload for MMIRS longslit target payload
|
|
144
153
|
|
|
145
|
-
payload
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
154
|
+
#example payload for MMIRS longslit target payload
|
|
155
|
+
payload = {
|
|
156
|
+
'objectid': 'AT2021fxy',
|
|
157
|
+
'ra': '13:13:01.560',
|
|
158
|
+
'dec': '-19:30:45.100',
|
|
159
|
+
'epoch': 'J2000',
|
|
160
|
+
'exposuretime': 450.0,
|
|
161
|
+
'filter': 'zJ',
|
|
162
|
+
'grism': 'J',
|
|
163
|
+
'magnitude': 16.9,
|
|
164
|
+
'maskid': 111,
|
|
165
|
+
'notes': 'Demo observation request. Please do not observe this.',
|
|
166
|
+
'numberexposures': 3,
|
|
167
|
+
'observationtype': 'longslit',
|
|
168
|
+
'priority': 3,
|
|
169
|
+
'slitwidth': '1pixel',
|
|
170
|
+
'targetofopportunity': 0,
|
|
171
|
+
'visits': 1,
|
|
172
|
+
'instrumentid':15,
|
|
173
|
+
'gain':'low',
|
|
174
|
+
'readtab': 'ramp_4.426',
|
|
175
|
+
'slitwidthproperty':'long',
|
|
176
|
+
'dithersize':'5'
|
|
177
|
+
}
|
|
150
178
|
|
|
151
179
|
#this will create the target along with validating the payload information. It will inform the user of any errors or warnings associated with the metadata
|
|
152
180
|
target = pymmt.Target(token=API_TOKEN,
|
|
@@ -235,14 +263,14 @@ if you don't pass any params into the function it will just find the current ins
|
|
|
235
263
|
|
|
236
264
|
```python
|
|
237
265
|
from datetime import datetime, timedelta
|
|
238
|
-
|
|
239
|
-
current_instruments =
|
|
266
|
+
insts = pymmt.Instruments()
|
|
267
|
+
current_instruments = insts.get_instruments()
|
|
240
268
|
|
|
241
269
|
#you can look into the future to see what instruments will be available:
|
|
242
|
-
future_instruments =
|
|
270
|
+
future_instruments = insts.get_instruments(date=datetime.datetime.now()+timedelta(months=1))
|
|
243
271
|
|
|
244
272
|
#you can look through the entire published schedule to see when a certain instrument will be on the telescope (Binospec = 16, MMIRS = 15)
|
|
245
|
-
my_instrument =
|
|
273
|
+
my_instrument = insts.get_instruments(instrumentid=16)
|
|
246
274
|
```
|
|
247
275
|
|
|
248
276
|
This function returns a list of dictionary elements with the values for:
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
import re
|
|
4
|
+
import time
|
|
5
|
+
from datetime import datetime
|
|
2
6
|
from pathlib import Path
|
|
3
|
-
|
|
7
|
+
|
|
8
|
+
import requests # type: ignore
|
|
9
|
+
|
|
10
|
+
from . import MMT_JSON_KEYS, isFloat, isInt
|
|
4
11
|
from .instruments.binospec import validate as bino_validate
|
|
5
12
|
from .instruments.mmirs import validate as mmirs_validate
|
|
6
|
-
from datetime import datetime
|
|
7
|
-
|
|
8
13
|
|
|
9
|
-
|
|
14
|
+
BASE_URL = "https://scheduler.mmto.arizona.edu/APIv2"
|
|
10
15
|
|
|
11
|
-
|
|
16
|
+
class api:
|
|
12
17
|
|
|
13
|
-
|
|
18
|
+
def __init__(self, base=BASE_URL, target=None, token=None):
|
|
19
|
+
self.base = base
|
|
14
20
|
self.target = target
|
|
15
21
|
|
|
16
22
|
if token is None:
|
|
@@ -62,7 +68,7 @@ class api():
|
|
|
62
68
|
|
|
63
69
|
|
|
64
70
|
class Target(api):
|
|
65
|
-
def __init__(self, token=None, verbose=True, payload={}):
|
|
71
|
+
def __init__(self, token=None, verbose=True, payload={}, base=BASE_URL):
|
|
66
72
|
self.verbose = verbose
|
|
67
73
|
self.valid = False
|
|
68
74
|
self.downloaded = False
|
|
@@ -73,7 +79,7 @@ class Target(api):
|
|
|
73
79
|
}
|
|
74
80
|
|
|
75
81
|
assert token is not None, 'Token cannot be None'
|
|
76
|
-
super().__init__('catalogTarget', token)
|
|
82
|
+
super().__init__(target='catalogTarget', token=token, base=base)
|
|
77
83
|
|
|
78
84
|
allowed_keys = list(MMT_JSON_KEYS)
|
|
79
85
|
self.__dict__.update((str(key).lower(), value) for key, value in payload.items() if str(key).lower() in allowed_keys)
|
|
@@ -94,7 +100,7 @@ class Target(api):
|
|
|
94
100
|
|
|
95
101
|
if 'ra' in selfkeys:
|
|
96
102
|
ra = selfdict['ra']
|
|
97
|
-
r = re.compile('.{2}:.{2}:.{2}\.*')
|
|
103
|
+
r = re.compile(r'.{2}:.{2}:.{2}\.*')
|
|
98
104
|
if not r.match(ra):
|
|
99
105
|
errors.append('Invalid format for field \'ra\' ['+ra+']. Valid format is dd:dd:dd.d')
|
|
100
106
|
else:
|
|
@@ -102,7 +108,7 @@ class Target(api):
|
|
|
102
108
|
|
|
103
109
|
if 'dec' in selfkeys:
|
|
104
110
|
dec = selfdict['dec']
|
|
105
|
-
r = re.compile('.{2}:.{2}:.{2}\.*')
|
|
111
|
+
r = re.compile(r'.{2}:.{2}:.{2}\.*')
|
|
106
112
|
isNeg = dec.startswith('-')
|
|
107
113
|
if '-' in dec:
|
|
108
114
|
dec = dec.split('-')[1]
|
|
@@ -460,9 +466,9 @@ class Target(api):
|
|
|
460
466
|
|
|
461
467
|
|
|
462
468
|
class Instruments(api):
|
|
463
|
-
def __init__(self, token=None, verbose=True, payload={}):
|
|
469
|
+
def __init__(self, token=None, verbose=True, payload={}, base=BASE_URL):
|
|
464
470
|
self. verbose = verbose
|
|
465
|
-
super().__init__('trimester//schedule/all/', token)
|
|
471
|
+
super().__init__(target='trimester//schedule/all/', token=token)
|
|
466
472
|
|
|
467
473
|
def get_instruments(self, date=None, instrumentid=None, getAll=False):
|
|
468
474
|
if date is None and instrumentid is None:
|
|
@@ -505,10 +511,10 @@ class Instruments(api):
|
|
|
505
511
|
|
|
506
512
|
|
|
507
513
|
class Datalist(api):
|
|
508
|
-
def __init__(self, token=None, verbose=True, payload={}):
|
|
514
|
+
def __init__(self, token=None, verbose=True, payload={}, base=BASE_URL):
|
|
509
515
|
self.verbose = verbose
|
|
510
516
|
self.data = []
|
|
511
|
-
super().__init__('data/list/catalogtarget', token)
|
|
517
|
+
super().__init__(target='data/list/catalogtarget', token=token)
|
|
512
518
|
|
|
513
519
|
|
|
514
520
|
def get(self, targetid, data_type='raw'):
|
|
@@ -530,9 +536,9 @@ class Datalist(api):
|
|
|
530
536
|
|
|
531
537
|
|
|
532
538
|
class Image(api):
|
|
533
|
-
def __init__(self, token=None, verbose=True, payload={}):
|
|
539
|
+
def __init__(self, token=None, verbose=True, payload={}, base=BASE_URL):
|
|
534
540
|
self. verbose = verbose
|
|
535
|
-
super().__init__('data/download/datafile', token)
|
|
541
|
+
super().__init__(target='data/download/datafile', token=token)
|
|
536
542
|
|
|
537
543
|
|
|
538
544
|
def get(self, datafileid=None, filepath=os.getcwd()):
|
PyMMT-1.0.0/tests/test.py
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import os, json, requests
|
|
2
|
-
from requests_toolbelt.multipart.encoder import MultipartEncoder
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def main():
|
|
6
|
-
|
|
7
|
-
token = '0f3732fcfb1c8577c390e71a176f3c8f'
|
|
8
|
-
catalogid = 486
|
|
9
|
-
targetid = 6302
|
|
10
|
-
programid = 977
|
|
11
|
-
url = 'https://scheduler.mmto.arizona.edu/upload.php'
|
|
12
|
-
finder = 'M51.jpg'
|
|
13
|
-
|
|
14
|
-
multipart_data = MultipartEncoder(
|
|
15
|
-
fields={
|
|
16
|
-
'finding_chart_file':(finder, open(finder, 'rb').read(), 'image/jpeg'),
|
|
17
|
-
'type':'finding_chart',
|
|
18
|
-
'token':token,
|
|
19
|
-
'catalog_id':str(catalogid),
|
|
20
|
-
'program_id':str(programid),
|
|
21
|
-
'target_id':str(targetid),
|
|
22
|
-
}
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
headers = {
|
|
26
|
-
'Content-Type':multipart_data.content_type,
|
|
27
|
-
'User-Agent':'Mozilla/5.0'
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
r = requests.post(url, headers=headers, data=multipart_data)
|
|
31
|
-
print(r.text)
|
|
32
|
-
|
|
33
|
-
main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|