@@ -520,7 +520,7 @@ class = 'galaxy' \
520520
521521 def get_spectra_async (self , coordinates = None , radius = 2. * u .arcsec ,
522522 matches = None , plate = None , fiberID = None , mjd = None ,
523- timeout = TIMEOUT ,
523+ timeout = TIMEOUT , get_query_payload = False ,
524524 data_release = conf .default_release , cache = True ,
525525 show_progress = True ):
526526 """
@@ -559,6 +559,9 @@ def get_spectra_async(self, coordinates=None, radius=2. * u.arcsec,
559559 timeout : float, optional
560560 Time limit (in seconds) for establishing successful connection with
561561 remote server. Defaults to `SDSSClass.TIMEOUT`.
562+ get_query_payload : bool, optional
563+ If True, this will return the data the query would have sent out,
564+ but does not actually do the query.
562565 data_release : int, optional
563566 The data release of the SDSS to use. With the default server, this
564567 only supports DR8 or later.
@@ -599,12 +602,19 @@ def get_spectra_async(self, coordinates=None, radius=2. * u.arcsec,
599602 if coordinates is None :
600603 matches = self .query_specobj (plate = plate , mjd = mjd , fiberID = fiberID ,
601604 fields = ['run2d' , 'plate' , 'mjd' , 'fiberID' ],
602- timeout = timeout , data_release = data_release , cache = cache )
605+ timeout = timeout , get_query_payload = get_query_payload ,
606+ data_release = data_release , cache = cache )
603607 else :
604- matches = self .query_crossid (coordinates , radius = radius ,
608+ matches = self .query_crossid (coordinates , radius = radius , timeout = timeout ,
605609 specobj_fields = ['run2d' , 'plate' , 'mjd' , 'fiberID' ],
606- spectro = True ,
607- timeout = timeout , data_release = data_release , cache = cache )
610+ spectro = True , get_query_payload = get_query_payload ,
611+ data_release = data_release , cache = cache )
612+ if get_query_payload :
613+ if coordinates is None :
614+ return matches
615+ else :
616+ return matches [0 ]
617+
608618 if matches is None :
609619 warnings .warn ("Query returned no results." , NoResultsWarning )
610620 return
@@ -640,8 +650,8 @@ def get_spectra_async(self, coordinates=None, radius=2. * u.arcsec,
640650 @prepend_docstr_nosections (get_spectra_async .__doc__ )
641651 def get_spectra (self , coordinates = None , radius = 2. * u .arcsec ,
642652 matches = None , plate = None , fiberID = None , mjd = None ,
643- timeout = TIMEOUT , cache = True ,
644- data_release = conf .default_release ,
653+ timeout = TIMEOUT , get_query_payload = False ,
654+ data_release = conf .default_release , cache = True ,
645655 show_progress = True ):
646656 """
647657 Returns
@@ -654,9 +664,14 @@ def get_spectra(self, coordinates=None, radius=2. * u.arcsec,
654664 radius = radius , matches = matches ,
655665 plate = plate , fiberID = fiberID ,
656666 mjd = mjd , timeout = timeout ,
667+ get_query_payload = get_query_payload ,
657668 data_release = data_release ,
669+ cache = cache ,
658670 show_progress = show_progress )
659671
672+ if get_query_payload :
673+ return readable_objs
674+
660675 if readable_objs is not None :
661676 if isinstance (readable_objs , dict ):
662677 return readable_objs
@@ -666,7 +681,7 @@ def get_spectra(self, coordinates=None, radius=2. * u.arcsec,
666681 def get_images_async (self , coordinates = None , radius = 2. * u .arcsec ,
667682 matches = None , run = None , rerun = 301 , camcol = None ,
668683 field = None , band = 'g' , timeout = TIMEOUT ,
669- cache = True ,
684+ cache = True , get_query_payload = False ,
670685 data_release = conf .default_release ,
671686 show_progress = True ):
672687 """
@@ -714,6 +729,9 @@ def get_images_async(self, coordinates=None, radius=2. * u.arcsec,
714729 timeout : float, optional
715730 Time limit (in seconds) for establishing successful connection with
716731 remote server. Defaults to `SDSSClass.TIMEOUT`.
732+ get_query_payload : bool, optional
733+ If True, this will return the data the query would have sent out,
734+ but does not actually do the query.
717735 cache : bool, optional
718736 Cache the images using astropy's caching system
719737 data_release : int, optional
@@ -753,12 +771,19 @@ def get_images_async(self, coordinates=None, radius=2. * u.arcsec,
753771 matches = self .query_photoobj (run = run , rerun = rerun ,
754772 camcol = camcol , field = field ,
755773 fields = ['run' , 'rerun' , 'camcol' , 'field' ],
756- timeout = timeout ,
774+ timeout = timeout , get_query_payload = get_query_payload ,
757775 data_release = data_release , cache = cache )
758776 else :
759- matches = self .query_crossid (coordinates , radius = radius ,
777+ matches = self .query_crossid (coordinates , radius = radius , timeout = timeout ,
760778 fields = ['run' , 'rerun' , 'camcol' , 'field' ],
761- timeout = timeout , data_release = data_release , cache = cache )
779+ get_query_payload = get_query_payload ,
780+ data_release = data_release , cache = cache )
781+ if get_query_payload :
782+ if coordinates is None :
783+ return matches
784+ else :
785+ return matches [0 ]
786+
762787 if matches is None :
763788 warnings .warn ("Query returned no results." , NoResultsWarning )
764789 return
@@ -798,10 +823,22 @@ def get_images(self, coordinates=None, radius=2. * u.arcsec,
798823
799824 """
800825
801- readable_objs = self .get_images_async (
802- coordinates = coordinates , radius = radius , matches = matches , run = run ,
803- rerun = rerun , data_release = data_release , camcol = camcol , field = field ,
804- band = band , timeout = timeout , show_progress = show_progress )
826+ readable_objs = self .get_images_async (coordinates = coordinates ,
827+ radius = radius ,
828+ matches = matches ,
829+ run = run ,
830+ rerun = rerun ,
831+ camcol = camcol ,
832+ field = field ,
833+ band = band ,
834+ timeout = timeout ,
835+ cache = cache ,
836+ get_query_payload = get_query_payload ,
837+ data_release = data_release ,
838+ show_progress = show_progress )
839+
840+ if get_query_payload :
841+ return readable_objs
805842
806843 if readable_objs is not None :
807844 if isinstance (readable_objs , dict ):
0 commit comments