2727class LineProfileInput (Schema ):
2828 """ Parse and validate input for the line profile endpoint """
2929 full_filename = fields .Str (required = True )
30+ s3_directory = fields .Str (required = True )
3031 start = fields .Dict (keys = fields .Str (), values = fields .Float (), required = True )
3132 end = fields .Dict (keys = fields .Str (), values = fields .Float (), required = True )
3233
@@ -54,12 +55,13 @@ def home():
5455def plotView ():
5556 """ This is a route to visualize the line requested for the line profile."""
5657 filename = request .args .get ('filename' )
58+ s3_directory = request .args .get ('s3_directory' )
5759 x0 = float (request .args .get ('x0' ))
5860 x1 = float (request .args .get ('x1' ))
5961 y0 = float (request .args .get ('y0' ))
6062 y1 = float (request .args .get ('y1' ))
6163
62- data = get_image_data (filename )
64+ data = get_image_data (filename , s3_directory )
6365 start = (x0 , y0 )
6466 end = (x1 , y1 )
6567 profile = get_intensity_profile (data , start , end )
@@ -77,11 +79,12 @@ def lineprofile():
7779 start (dict): 'x' and 'y' values for the line start point, in [0, 1]
7880 end (dict): same as start
7981 full_filename (str): photon ranch filename in s3, including the extension.
82+ s3_directory (str): the 'folder' that the image resides in s3. [ data | info-images | allsky ]
8083
8184 Example post request:
8285 curl -X POST http://localhost:5000/lineprofile -F \
8386 'data={"start":{"x": 0, "y":0}, "end": {"x": 1, "y": 1},
84- "full_filename": "tst-test-20201112-00000058-EX01.fits.bz2"}'
87+ "full_filename": "tst-test-20201112-00000058-EX01.fits.bz2", "s3_directory": "data" }'
8588
8689 """
8790
@@ -91,16 +94,17 @@ def lineprofile():
9194 start = (args ['start' ]['x' ], args ['start' ]['y' ])
9295 end = (args ['end' ]['x' ], args ['end' ]['y' ])
9396 full_filename = args ['full_filename' ]
97+ s3_directory = args ['s3_directory' ]
9498
9599 # Make sure the requested file exists
96- if not check_if_s3_image_exists (full_filename ):
100+ if not check_if_s3_image_exists (full_filename , s3_directory ):
97101 return jsonify ({
98102 "success" : False ,
99- "message" : f"Image does not exist: { full_filename } ."
103+ "message" : f"Image does not exist: { s3_directory } / { full_filename } ."
100104 }), 400
101105
102106 # Get the image data and compute a line profile
103- data = get_image_data (full_filename )
107+ data = get_image_data (full_filename , s3_directory )
104108 profile = get_intensity_profile (data , start , end )
105109
106110 response = jsonify ({
@@ -134,15 +138,16 @@ def image_statistics():
134138
135139 args = json .loads (request .data )
136140 full_filename = args ['full_filename' ]
141+ s3_directory = args ['s3_directory' ]
137142
138143 # Make sure the requested file exists
139- if not check_if_s3_image_exists (full_filename ):
144+ if not check_if_s3_image_exists (full_filename , s3_directory ):
140145 return jsonify ({
141146 "success" : False ,
142- "message" : f"Image does not exist: { full_filename } ."
147+ "message" : f"Image does not exist: { s3_directory } / { full_filename } ."
143148 }), 400
144149
145- image_data = get_image_data (full_filename )
150+ image_data = get_image_data (full_filename , s3_directory )
146151 if 'subregion' in args .keys ():
147152 coords = args ['subregion' ]
148153 image_data = get_subregion_rect (image_data , coords ['x0' ], coords ['x1' ], coords ['y0' ], coords ['y1' ] )
@@ -172,6 +177,7 @@ def histogram():
172177
173178 POST Args:
174179 full_filename (str): full file name for analysis, including the file extensions.
180+ s3_directory (str): the 'folder' that the image resides in s3. [ data | info-images | allsky ]
175181 clip_percent (float): percentile value of intensity to define min and max range of histogram
176182 subregion (dict): optional, analyze subregion of image
177183 subregion['shape'] (str): type of shape. Currently only supports 'rect'.
@@ -186,17 +192,18 @@ def histogram():
186192
187193 args = json .loads (request .data )
188194 full_filename = args ['full_filename' ]
195+ s3_directory = args ['s3_directory' ]
189196 clip_percent = args ['clip_percent' ]
190197 print (full_filename , clip_percent )
191198
192199 # Make sure the requested file exists
193- if not check_if_s3_image_exists (full_filename ):
200+ if not check_if_s3_image_exists (full_filename , s3_directory ):
194201 return jsonify ({
195202 "success" : False ,
196- "message" : f"Image does not exist: { full_filename } ."
203+ "message" : f"Image does not exist: { s3_directory } / { full_filename } ."
197204 }), 400
198205
199- image_data = get_image_data (full_filename )
206+ image_data = get_image_data (full_filename , s3_directory )
200207 if 'subregion' in args .keys ():
201208 coords = args ['subregion' ]
202209 image_data = get_subregion_rect (image_data , coords ['x0' ], coords ['x1' ], coords ['y0' ], coords ['y1' ] )
0 commit comments