Skip to content

Commit b1de4d4

Browse files
committed
add the ability to pass chemical_name directly to the server (which
isn't directly relevant to this issue but looked like it could have been and was important for testing), and change the default exclusion to 'none' instead of None
1 parent 3e3fc89 commit b1de4d4

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

astroquery/splatalogue/core.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,15 @@ def _parse_kwargs(self, min_frequency=None, max_frequency=None,
123123
chem_re_flags=0, energy_min=None, energy_max=None,
124124
energy_type=None, intensity_lower_limit=None,
125125
intensity_type=None, transition=None, version=None,
126-
exclude=None, only_NRAO_recommended=None,
126+
exclude='none', only_NRAO_recommended=None,
127127
line_lists=None, line_strengths=None, energy_levels=None,
128128
export=None, export_limit=None, noHFS=None,
129129
displayHFS=None, show_unres_qn=None,
130130
show_upper_degeneracy=None, show_molecule_tag=None,
131131
show_qn_code=None, show_lovas_labref=None,
132132
show_lovas_obsref=None, show_orderedfreq_only=None,
133-
show_nrao_recommended=None):
133+
show_nrao_recommended=None,
134+
parse_chemistry_locally=False):
134135
"""
135136
The Splatalogue service returns lines with rest frequencies in the
136137
range [min_frequency, max_frequency].
@@ -165,7 +166,9 @@ def _parse_kwargs(self, min_frequency=None, max_frequency=None,
165166
166167
``' H2CO '`` - Just 1 species, H2CO. The spaces prevent including
167168
others.
168-
169+
parse_chemistry_locally : bool
170+
Attempt to determine the species ID #'s locally before sending the
171+
query? This will prevent queries that have no matching species.
169172
chem_re_flags : int
170173
See the `re` module
171174
energy_min : `None` or float
@@ -267,10 +270,13 @@ def _parse_kwargs(self, min_frequency=None, max_frequency=None,
267270
# include all
268271
payload['sid[]'] = []
269272
elif chemical_name is not None:
270-
species_ids = self.get_species_ids(chemical_name, chem_re_flags)
271-
if len(species_ids) == 0:
272-
raise ValueError("No matching chemical species found.")
273-
payload['sid[]'] = list(species_ids.values())
273+
if parse_chemistry_locally:
274+
species_ids = self.get_species_ids(chemical_name, chem_re_flags)
275+
if len(species_ids) == 0:
276+
raise ValueError("No matching chemical species found.")
277+
payload['sid[]'] = list(species_ids.values())
278+
else:
279+
payload['chemical_name'] = chemical_name
274280

275281
if energy_min is not None:
276282
payload['energy_range_from'] = float(energy_min)
@@ -295,7 +301,6 @@ def _parse_kwargs(self, min_frequency=None, max_frequency=None,
295301
"are {vers}".format(vers=str(self.versions)))
296302

297303
if exclude == 'none':
298-
log.debug("Exclude is 'none'")
299304
for e in ('potential', 'atmospheric', 'probable', 'known'):
300305
# Setting a keyword value to 'None' removes it (see query_lines_async)
301306
log.debug("Setting no_{0} to None".format(e))

0 commit comments

Comments
 (0)