From ac59149e671516650435b7ca092908f8485e49d4 Mon Sep 17 00:00:00 2001 From: Adrian Damian Date: Thu, 13 Jun 2024 14:38:35 -0700 Subject: [PATCH] Added support for spectral_resolution in ALMA --- CHANGES.rst | 1 + astroquery/alma/core.py | 15 +++++----- astroquery/alma/tapsql.py | 32 ---------------------- astroquery/alma/tests/data/alma-onerow.txt | 4 +-- astroquery/alma/tests/test_alma.py | 24 ++++++++-------- 5 files changed, 23 insertions(+), 53 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 0818cdbfd6..cedc68e8e8 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -12,6 +12,7 @@ alma ^^^^ - Added method to return quantities instead of values and regions footprint in alma [#2855] +- Added support for frequency_resolution in KHz [#3035] mpc ^^^ diff --git a/astroquery/alma/core.py b/astroquery/alma/core.py index 99e3aea501..947d24d53b 100644 --- a/astroquery/alma/core.py +++ b/astroquery/alma/core.py @@ -29,7 +29,7 @@ from ..query import BaseQuery, QueryWithLogin, BaseVOQuery from .tapsql import (_gen_pos_sql, _gen_str_sql, _gen_numeric_sql, _gen_band_list_sql, _gen_datetime_sql, _gen_pol_sql, _gen_pub_sql, - _gen_science_sql, _gen_spec_res_sql, ALMA_DATE_FORMAT) + _gen_science_sql, ALMA_DATE_FORMAT) from . import conf, auth_urls from astroquery.exceptions import CorruptDataWarning @@ -51,7 +51,8 @@ 'gal_latitude': 'Galactic latitude', 'band_list': 'Band', 's_region': 'Footprint', - 'em_resolution': 'Frequency resolution', + 'em_resolution': 'Frequency resolution (m)', + 'spectral_resolution': 'Frequency resolution (Hz)', 'antenna_arrays': 'Array', 'is_mosaic': 'Mosaic', 't_exptime': 'Integration', @@ -111,7 +112,9 @@ 'Frequency (GHz)': ['frequency', 'frequency', _gen_numeric_sql], 'Bandwidth (Hz)': ['bandwidth', 'bandwidth', _gen_numeric_sql], 'Spectral resolution (KHz)': ['spectral_resolution', - 'em_resolution', _gen_spec_res_sql], + 'spectral_resolution', _gen_numeric_sql], + 'Spectral resolution (m)': ['em_resolution', + 'em_resolution', _gen_numeric_sql], 'Band': ['band_list', 'band_list', _gen_band_list_sql] }, 'Time': { @@ -182,11 +185,7 @@ def _gen_sql(payload): # use the value and the second entry in attrib which # is the new name of the column val = payload[constraint] - if constraint == 'em_resolution': - # em_resolution does not require any transformation - attrib_where = _gen_numeric_sql(constraint, val) - else: - attrib_where = attrib[2](attrib[1], val) + attrib_where = attrib[2](attrib[1], val) if attrib_where: if where: where += ' AND ' diff --git a/astroquery/alma/tapsql.py b/astroquery/alma/tapsql.py index a000f0660e..b6357baf12 100644 --- a/astroquery/alma/tapsql.py +++ b/astroquery/alma/tapsql.py @@ -167,38 +167,6 @@ def _gen_datetime_sql(field, value): return result -def _gen_spec_res_sql(field, value): - # This needs special treatment because spectral_resolution in AQ is in - # KHz while corresponding em_resolution is in m - result = '' - for interval in _val_parse(value): - if result: - result += ' OR ' - if isinstance(interval, tuple): - min_val, max_val = interval - if max_val is None: - result += "{}<={}".format( - field, - min_val*u.kHz.to(u.m, equivalencies=u.spectral())) - elif min_val is None: - result += "{}>={}".format( - field, - max_val*u.kHz.to(u.m, equivalencies=u.spectral())) - else: - result += "({1}<={0} AND {0}<={2})".format( - field, - max_val*u.kHz.to(u.m, equivalencies=u.spectral()), - min_val*u.kHz.to(u.m, equivalencies=u.spectral())) - else: - result += "{}={}".format( - field, interval*u.kHz.to(u.m, equivalencies=u.spectral())) - if ' OR ' in result: - # use brackets for multiple ORs - return '(' + result + ')' - else: - return result - - def _gen_pub_sql(field, value): if value is True: return "{}='Public'".format(field) diff --git a/astroquery/alma/tests/data/alma-onerow.txt b/astroquery/alma/tests/data/alma-onerow.txt index b1f928d77d..db539020bf 100644 --- a/astroquery/alma/tests/data/alma-onerow.txt +++ b/astroquery/alma/tests/data/alma-onerow.txt @@ -1,2 +1,2 @@ -obs_publisher_did obs_collection facility_name instrument_name obs_id dataproduct_type calib_level target_name s_ra s_dec s_fov s_region s_resolution t_min t_max t_exptime t_resolution em_min em_max em_res_power pol_states o_ucd access_url access_format proposal_id data_rights gal_longitude gal_latitude band_list em_resolution bandwidth antenna_arrays is_mosaic obs_release_date spatial_resolution frequency_support frequency velocity_resolution obs_creator_name pub_title first_author authors pub_abstract publication_year proposal_abstract schedblock_name proposal_authors sensitivity_10kms cont_sensitivity_bandwidth pwv group_ous_uid member_ous_uid asdm_uid obs_title type scan_intent science_observation spatial_scale_max qa2_passed bib_reference science_keyword scientific_category lastModified -ADS/JAO.ALMA#2017.1.00079.S ALMA JAO ALMA uid://A001/X1295/X35 cube 2 M83 204.24712522989094 -29.868853678162907 0.1650122764060855 "b'Polygon ICRS 204.319476 -29.894283 204.314307 -29.893360 204.174614 -29.893832 204.159606 -29.886181 204.153471 -29.877399 204.157057 -29.856075 204.152987 -29.849020 204.155142 -29.845057 204.159570 -29.842949 204.165241 -29.843807 204.183416 -29.843187 204.297720 -29.843831 204.302372 -29.842863 204.307818 -29.845083 204.310143 -29.850046 204.314283 -29.849063 204.334321 -29.849727 204.337744 -29.852341 204.343021 -29.861027 204.339032 -29.868522 204.342934 -29.888997 204.337052 -29.894104'" 1.5779219110458824 58480.431262 58488.516277 156.52 156.52 0.002624500730920478 0.002668272377703091 58490.401574578646 /XX/YY/ phot.flux.density;phys.polarization http://almascience.org/aq?member_ous_id=uid://A001/X1295/X35 text/html 2017.1.00079.S Public 314.57611565717997 31.970814026685794 3 36592333492997.875 1875000000.0 "A001:DA44 A002:DA51 A003:DV12 A004:DV18 A005:DA58 A006:DV25 A007:DV05 A008:DV07 A010:DV13 A011:DV21 A015:DA64 A016:DV11 A017:DV14 A018:DA54 A019:DA61 A022:DV23 A023:DA42 A024:DA49 A025:DA46 A026:DV19 A027:DV06 A033:DA53 A034:DA50 A035:DA43 A036:DA45 A039:DA56 A040:DA55 A041:DA57 A042:DV08 A043:DA60 A044:DV03 A045:DV01 A047:DV15 A048:DV02 A049:DA47 A050:DA62 A058:DA41 A060:DV17 A062:DV10 A066:DV04 A068:DA65 A069:DV16 A070:DA48 A072:DV20 A073:DA54 A074:DV09 A075:DV18 A076:DA59 A082:DA52 A083:DV22 A085:DA63 A088:DV24" T b'2020-03-03T03:20:58.000' 1.5779219110458824 "[112.35..114.23GHz,1952.95kHz,8mJy/beam@10km/s,360.2uJy/beam@native, XX YY] U [113.81..115.79GHz,31247.16kHz,9.9mJy/beam@10km/s,433.6uJy/beam@native, XX YY] U [114.84..115.31GHz,488.24kHz,8.2mJy/beam@10km/s,739.3uJy/beam@native, XX YY] U [114.95..115.19GHz,122.06kHz,8.2mJy/beam@10km/s,1mJy/beam@native, XX YY]" 114.07366301863082 317.6733782195699 "Koda, Jin" "" "" "" "" "" "We propose a full mapping of the cold molecular gas over the whole disk of M83 in CO(1-0) using ALMA 12m+7m+TP. This closest (d=4.5Mpc) face-on (i<30deg) archetypical barred spiral galaxy closely resembles our own Milky Way, and has been the important showcase for multi-wavelength studies. The proposed ALMA CO(1-0) map will not only detect the smallest clouds at the lowest end of the cloud mass function (10^4Msun), but also reveal the more extended, ambient molecular gas outside GMCs. This full census of the molecular ISM will be correlated with galactic environments and star formation, from the molecule-dominated galactic center to the atom-dominated outskirts, across the bar, spiral arms, and interarm regions. In combination with the ALMA CO(2-1) map (Cycle 4), we will use the CO 2-1/1-0 ratios of all GMCs to diagnose their physical states and variations as a function of the environments. We will also test the paradigm of GMCs as physical entities by measuring the partition between GMCs and the ambient molecular gas. The ALMA CO(1-0) map will become the foundation for future ALMA studies at higher resolution and in other molecular lines." M83_e_03_TM1 "Oka, Tomoharu; Wu, Yu-Ting; Muraoka, Kazuyuki; Madore, Barry; Watanabe, Yoshimasa; Nakanishi, Kouichiro; Sakamoto, Kazushi; Boissier, Samuel; Seibert, Mark; Martin, Sergio; Sawada, Tsuyoshi; Kuno, Nario; Vlahakis, Catherine; Donovan Meyer, Jennifer; Elmegreen, Bruce; Harada, Nanase; Heyer, Mark; Keto, Eric; Hirota, Akihiko; Kobayashi, Masato; Ohyama, Youichi; Scoville, Nick; Ho, Luis; Tosaki, Tomoka; Egusa, Fumi; Onodera, Sachiko; Gil de Paz, Armando;" 8.023585259543626 0.25181849902410236 5.474677085876465 uid://A001/X1295/X34 uid://A001/X1295/X35 uid://A002/Xd74c3f/Xcf20 "Mapping Molecular ISM in the Whole Disk of M83" S TARGET T 21.61875828636442 T "" "Spiral galaxies, Giant Molecular Clouds (GMC) properties" "Local Universe" b'2019-12-11T20:57:17.290' +obs_publisher_did obs_collection facility_name instrument_name obs_id dataproduct_type calib_level target_name s_ra s_dec s_fov s_region s_resolution t_min t_max t_exptime t_resolution em_min em_max em_res_power pol_states o_ucd access_url access_format proposal_id data_rights gal_longitude gal_latitude band_list em_resolution bandwidth antenna_arrays is_mosaic obs_release_date spatial_resolution frequency_support frequency velocity_resolution obs_creator_name pub_title first_author authors pub_abstract publication_year proposal_abstract schedblock_name proposal_authors sensitivity_10kms cont_sensitivity_bandwidth pwv group_ous_uid member_ous_uid asdm_uid obs_title type scan_intent science_observation spatial_scale_max qa2_passed bib_reference science_keyword scientific_category spectral_resolution lastModified +ADS/JAO.ALMA#2017.1.00079.S ALMA JAO ALMA uid://A001/X1295/X35 cube 2 M83 204.24712522989094 -29.868853678162907 0.1650122764060855 "b'Polygon ICRS 204.319476 -29.894283 204.314307 -29.893360 204.174614 -29.893832 204.159606 -29.886181 204.153471 -29.877399 204.157057 -29.856075 204.152987 -29.849020 204.155142 -29.845057 204.159570 -29.842949 204.165241 -29.843807 204.183416 -29.843187 204.297720 -29.843831 204.302372 -29.842863 204.307818 -29.845083 204.310143 -29.850046 204.314283 -29.849063 204.334321 -29.849727 204.337744 -29.852341 204.343021 -29.861027 204.339032 -29.868522 204.342934 -29.888997 204.337052 -29.894104'" 1.5779219110458824 58480.431262 58488.516277 156.52 156.52 0.002624500730920478 0.002668272377703091 58490.401574578646 /XX/YY/ phot.flux.density;phys.polarization http://almascience.org/aq?member_ous_id=uid://A001/X1295/X35 text/html 2017.1.00079.S Public 314.57611565717997 31.970814026685794 3 36592333492997.875 1875000000.0 "A001:DA44 A002:DA51 A003:DV12 A004:DV18 A005:DA58 A006:DV25 A007:DV05 A008:DV07 A010:DV13 A011:DV21 A015:DA64 A016:DV11 A017:DV14 A018:DA54 A019:DA61 A022:DV23 A023:DA42 A024:DA49 A025:DA46 A026:DV19 A027:DV06 A033:DA53 A034:DA50 A035:DA43 A036:DA45 A039:DA56 A040:DA55 A041:DA57 A042:DV08 A043:DA60 A044:DV03 A045:DV01 A047:DV15 A048:DV02 A049:DA47 A050:DA62 A058:DA41 A060:DV17 A062:DV10 A066:DV04 A068:DA65 A069:DV16 A070:DA48 A072:DV20 A073:DA54 A074:DV09 A075:DV18 A076:DA59 A082:DA52 A083:DV22 A085:DA63 A088:DV24" T b'2020-03-03T03:20:58.000' 1.5779219110458824 "[112.35..114.23GHz,1952.95kHz,8mJy/beam@10km/s,360.2uJy/beam@native, XX YY] U [113.81..115.79GHz,31247.16kHz,9.9mJy/beam@10km/s,433.6uJy/beam@native, XX YY] U [114.84..115.31GHz,488.24kHz,8.2mJy/beam@10km/s,739.3uJy/beam@native, XX YY] U [114.95..115.19GHz,122.06kHz,8.2mJy/beam@10km/s,1mJy/beam@native, XX YY]" 114.07366301863082 317.6733782195699 "Koda, Jin" "" "" "" "" "" "We propose a full mapping of the cold molecular gas over the whole disk of M83 in CO(1-0) using ALMA 12m+7m+TP. This closest (d=4.5Mpc) face-on (i<30deg) archetypical barred spiral galaxy closely resembles our own Milky Way, and has been the important showcase for multi-wavelength studies. The proposed ALMA CO(1-0) map will not only detect the smallest clouds at the lowest end of the cloud mass function (10^4Msun), but also reveal the more extended, ambient molecular gas outside GMCs. This full census of the molecular ISM will be correlated with galactic environments and star formation, from the molecule-dominated galactic center to the atom-dominated outskirts, across the bar, spiral arms, and interarm regions. In combination with the ALMA CO(2-1) map (Cycle 4), we will use the CO 2-1/1-0 ratios of all GMCs to diagnose their physical states and variations as a function of the environments. We will also test the paradigm of GMCs as physical entities by measuring the partition between GMCs and the ambient molecular gas. The ALMA CO(1-0) map will become the foundation for future ALMA studies at higher resolution and in other molecular lines." M83_e_03_TM1 "Oka, Tomoharu; Wu, Yu-Ting; Muraoka, Kazuyuki; Madore, Barry; Watanabe, Yoshimasa; Nakanishi, Kouichiro; Sakamoto, Kazushi; Boissier, Samuel; Seibert, Mark; Martin, Sergio; Sawada, Tsuyoshi; Kuno, Nario; Vlahakis, Catherine; Donovan Meyer, Jennifer; Elmegreen, Bruce; Harada, Nanase; Heyer, Mark; Keto, Eric; Hirota, Akihiko; Kobayashi, Masato; Ohyama, Youichi; Scoville, Nick; Ho, Luis; Tosaki, Tomoka; Egusa, Fumi; Onodera, Sachiko; Gil de Paz, Armando;" 8.023585259543626 0.25181849902410236 5.474677085876465 uid://A001/X1295/X34 uid://A001/X1295/X35 uid://A002/Xd74c3f/Xcf20 "Mapping Molecular ISM in the Whole Disk of M83" S TARGET T 21.61875828636442 T "" "Spiral galaxies, Giant Molecular Clouds (GMC) properties" "Local Universe" 2000000 b'2019-12-11T20:57:17.290' diff --git a/astroquery/alma/tests/test_alma.py b/astroquery/alma/tests/test_alma.py index c6c1177ac8..19f3fd0170 100644 --- a/astroquery/alma/tests/test_alma.py +++ b/astroquery/alma/tests/test_alma.py @@ -199,17 +199,6 @@ def test_gen_datetime_sql(): common_select + "(58849.0<=t_min AND t_min<=58880.0)" -def test_gen_spec_res_sql(): - common_select = 'select * from ivoa.obscore WHERE ' - assert _gen_sql({'spectral_resolution': 70}) == common_select + "em_resolution=20985472.06" - assert _gen_sql({'spectral_resolution': '<70'}) == common_select + "em_resolution>=20985472.06" - assert _gen_sql({'spectral_resolution': '>70'}) == common_select + "em_resolution<=20985472.06" - assert _gen_sql({'spectral_resolution': '(70 .. 80)'}) == common_select + \ - "(23983396.64<=em_resolution AND em_resolution<=20985472.06)" - assert _gen_sql({'spectral_resolution': '(70|80)'}) == common_select + \ - "(em_resolution=20985472.06 OR em_resolution=23983396.64)" - - def test_gen_public_sql(): common_select = 'select * from ivoa.obscore' assert _gen_sql({'public_data': None}) == common_select @@ -356,6 +345,19 @@ def test_query(): language='ADQL', maxrec=None ) + tap_mock.reset() + result = alma.query_region('1 2', radius=1*u.deg, + payload={'em_resolution': 6.929551916151968e-05, + 'spectral_resolution': 2000000} + ) + assert len(result) == 0 + tap_mock.search.assert_called_with( + "select * from ivoa.obscore WHERE em_resolution=6.929551916151968e-05 " + "AND spectral_resolution=2000000 " + "AND (INTERSECTS(CIRCLE('ICRS',1.0,2.0,1.0), " + "s_region) = 1) AND science_observation='T' AND data_rights='Public'", + language='ADQL', maxrec=None) + @pytest.mark.filterwarnings("ignore::astropy.utils.exceptions.AstropyUserWarning") def test_enhanced_table():