Skip to content

Commit 9b7f976

Browse files
committed
Improved documentation and input check
1 parent c8e404f commit 9b7f976

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

astroquery/esasky/core.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -809,9 +809,9 @@ def get_images(self, position="", radius=__ZERO_ARCMIN_STRING,
809809
810810
Parameters
811811
----------
812-
position : str or `astropy.coordinates` object
812+
position : str or `astropy.coordinates` object, optional
813813
Can either be a string of the location, eg 'M51', or the coordinates
814-
of the object.
814+
of the object. An input is required for either position or observation_ids.
815815
radius : str or `~astropy.units.Quantity`, optional
816816
The radius of a region. Defaults to 0.
817817
missions : string or list, optional
@@ -827,6 +827,7 @@ def get_images(self, position="", radius=__ZERO_ARCMIN_STRING,
827827
observation_ids : string or list, optional
828828
A list of observation ID's, you would like to download.
829829
If this parameter is empty, a cone search will be performed instead using the radius and position.
830+
An input is required for either position or observation_ids.
830831
831832
Returns
832833
-------
@@ -852,6 +853,8 @@ def get_images(self, position="", radius=__ZERO_ARCMIN_STRING,
852853
"1342247257", "30002561-25100", "hst_07553_3h_wfpc2_f160bw_pc", "ocli05leq"]
853854
get_images(observation_ids=observation_ids, missions=missions)
854855
"""
856+
if position == "" and observation_ids is None:
857+
raise ValueError("An input is required for either position or observation_ids.")
855858
sanitized_position = self._sanitize_input_position(position)
856859
sanitized_radius = self._sanitize_input_radius(radius)
857860
sanitized_missions = self._sanitize_input_mission(missions)
@@ -900,9 +903,9 @@ def get_spectra(self, position="", radius=__ZERO_ARCMIN_STRING,
900903
901904
Parameters
902905
----------
903-
position : str or `astropy.coordinates` object
906+
position : str or `astropy.coordinates` object, optional
904907
Can either be a string of the location, eg 'M51', or the coordinates
905-
of the object.
908+
of the object. An input is required for either position or observation_ids.
906909
radius : str or `~astropy.units.Quantity`, optional
907910
The radius of a region. Defaults to 0.
908911
missions : string or list, optional
@@ -918,6 +921,7 @@ def get_spectra(self, position="", radius=__ZERO_ARCMIN_STRING,
918921
observation_ids : string or list, optional
919922
A list of observation ID's, you would like to download.
920923
If this parameter is empty, a cone search will be performed instead using the radius and position.
924+
An input is required for either position or observation_ids.
921925
922926
Returns
923927
-------
@@ -945,6 +949,8 @@ def get_spectra(self, position="", radius=__ZERO_ARCMIN_STRING,
945949
get_spectra(observation_ids=observation_ids, missions=missions)
946950
947951
"""
952+
if position == "" and observation_ids is None:
953+
raise ValueError("An input is required for either position or observation_ids.")
948954
sanitized_position = self._sanitize_input_position(position)
949955
sanitized_radius = self._sanitize_input_radius(radius)
950956
sanitized_missions = self._sanitize_input_spectra(missions)
@@ -1368,7 +1374,7 @@ def _build_region_query(self, coordinates, radius, row_limit, json):
13681374
select_query = "SELECT "
13691375
if row_limit > 0:
13701376
select_query = "".join([select_query, "TOP {} ".format(row_limit)])
1371-
elif not row_limit == -1:
1377+
elif row_limit != -1:
13721378
raise ValueError("Invalid value of row_limit")
13731379

13741380
select_query = "".join([select_query, "* "])
@@ -1408,7 +1414,7 @@ def _build_id_query(self, ids, row_limit, json):
14081414
select_query = "SELECT "
14091415
if row_limit > 0:
14101416
select_query = "".join([select_query, "TOP {} ".format(row_limit)])
1411-
elif not row_limit == -1:
1417+
elif row_limit != -1:
14121418
raise ValueError("Invalid value of row_limit")
14131419

14141420
select_query = "".join([select_query, "* "])

0 commit comments

Comments
 (0)