def test_post_wave_series(client): with pytest.raises( TypeError, match="The series hmi.M_45s does not support wavelength attribute." ): client.search( a.Time('2020/1/1T00:00:00', '2020/1/1T00:00:45'), a.jsoc.Series('hmi.M_45s') | a.jsoc.Series('aia.lev1_euv_12s'), a.Wavelength(193 * u.AA) | a.Wavelength(335 * u.AA))
def test_post_wavelength(client): responses = client.search( a.Time('2020/07/30T13:30:00', '2020/07/30T14:00:00'), a.jsoc.Series('aia.lev1_euv_12s'), a.Wavelength(193 * u.AA) | a.Wavelength(335 * u.AA), a.jsoc.Notify('*****@*****.**')) aa = client.request_data(responses) [r.wait() for r in aa] tmpresp = aa[0]._d assert tmpresp['protocol'] == 'fits' assert tmpresp['method'] == 'url' assert tmpresp['count'] == '302' tmpresp = aa[1]._d assert tmpresp['protocol'] == 'fits' assert tmpresp['method'] == 'url' assert tmpresp['count'] == '302'
def get_image(t, x, y): """ This function gets an AIA EUV image from the SDO (AIA = Atmospheric Imaging Assembly, EUV = Extreme UltraViolent, SDO = SOlar Dynamics Observatory) at a given time t, and crops the image to given location x, y. Param: t datetime, the datetime of the flare x integer, the longitude position of the flare in arcsec y integer, the latitude position of the flare in arcsec Return: aia_sub sunpy Map, the cropped image """ # request the data for the given time result = Fido.search(a.Time(t - dt.timedelta(seconds=10), t), a.Instrument("aia"), a.Wavelength(94 * u.angstrom), a.vso.Sample(12 * u.second)) print('found result') #print(result) # download the data file_download = Fido.fetch(result[0, -1], site='ROB') print('downloaded data') #print(file_download) # load the data to a sun map aia1 = sunpy.map.Map(file_download) print('loaded to sun map') #print(aia1) # calibrate it aia = aiaprep(aia1) print('calibrated') # plot it aia.plot() plt.colorbar() #plt.show() # get the co-ordinates of the top right and bottom left of the crop box co_ords = get_box_coord(x, y, 100) tr = co_ords[1] bl = co_ords[2] # sub-map top_right = SkyCoord(tr[0] * u.arcsec, tr[1] * u.arcsec, frame=aia.coordinate_frame) bottom_left = SkyCoord(bl[0] * u.arcsec, bl[1] * u.arcsec, frame=aia.coordinate_frame) aia_sub = aia.submap(top_right, bottom_left) aia_sub.plot_settings['cmap'] = plt.get_cmap('Greys_r') ax = plt.subplot(projection=aia_sub) aia_sub.plot() #plt.show() print('made sub map') return aia_sub
def qr_block_with_missing_physobs(): return vso.VSOClient().search( net_attrs.Time('20130805T120000', '20130805T121000'), net_attrs.Instrument('SWAVES'), net_attrs.Source('STEREO_A'), net_attrs.Provider('SSC'), net_attrs.Wavelength( 10 * u.kHz, 160 * u.kHz), response_format="legacy")[0]
def _check_wavelengths(cls, wavelength): """ Check for overlap between given wavelength and receiver frequency coverage defined in `RECEIVER_FREQUENCIES`. Parameters ---------- wavelength : `sunpy.net.attrs.Wavelength` Input wavelength range to check Returns ------- `list` List of receivers names or empty list if no overlap """ # Input wavelength range is completely contained in one receiver range receivers = [ k for k, v in RECEIVER_FREQUENCIES.items() if wavelength in v ] # If not defined need to continue if not receivers: # Overlaps but not contained in, either max in lfr or min hfr if wavelength.min in RECEIVER_FREQUENCIES['rad2'] or \ wavelength.max in RECEIVER_FREQUENCIES['rad2']: receivers.append('rad2') if wavelength.min in RECEIVER_FREQUENCIES['rad1'] or \ wavelength.max in RECEIVER_FREQUENCIES['rad1']: receivers.append('rad1') # min in lfr and max in hfr # min and max of combined lft and hfr contained in give wavelength range if a.Wavelength(RECEIVER_FREQUENCIES['rad1'].min, RECEIVER_FREQUENCIES['rad2'].max) in wavelength: receivers = ['rad1', 'rad2'] # If we get here the is no overlap so set to empty list return receivers
def download_and_gen_carrmap(dt, resample_size=None): # Saves fits files to ~/sunpy/data stereoA = (a.vso.Source('STEREO_A') & a.Instrument('EUVI') & a.Time( time_string(dt), time_string(dt + timedelta(minutes=60)))) stereoB = (a.vso.Source('STEREO_B') & a.Instrument('EUVI') & a.Time( time_string(dt), time_string(dt + timedelta(minutes=60)))) aia = (a.Instrument('AIA') & a.Time(time_string(dt), time_string(dt + timedelta(minutes=60)))) wave = a.Wavelength(19 * u.nm, 20 * u.nm) res = Fido.search(wave, aia | stereoA | stereoB) files = [] for jj in range(len(res)): try: files.append(Fido.fetch(res[jj, 0])) except: "" maps = [m for m in sunpy.map.Map(files)] carrmaps = [ get_carr_map(map_, resample_size=resample_size) for map_ in maps ] lons, lats = carrmaps[0][0:2] # Quick process maps to have same floor value (0) and same median quick_procs_list = [] for arr in carrmaps[:]: arr = arr[2] quick_proc = arr - np.nanmin(arr) quick_procs_list.append(quick_proc / np.nanmedian(quick_proc)) combined = np.nanmean(np.array(quick_procs_list), axis=0) return lons, lats, combined, maps
def loadData(s_map: Map): query = Fido.search(attrs.Time(s_map.tstart.isoformat(), s_map.tstart.isoformat()), attrs.Instrument(s_map.instrument), attrs.Wavelength(s_map.wavelength * u.AA)) query = query[0, 0] if not s_map.id.startswith(list(query.responses)[0][0].fileid): raise Exception("ERROR: invalid search result encountered!") return Fido.fetch(query, progress=True)
def test_rstn(parse_path_moc): start_time = Time('2020-01-01T06:17:38.000') end_time = Time('2020-01-01T15:27:43.000') meta = { 'instrument': 'RSTN', 'observatory': 'San Vito', 'start_time': start_time, 'end_time': end_time, 'detector': 'RSTN', 'wavelength': a.Wavelength(25000.0 * u.kHz, 180000.0 * u.kHz), 'freqs': np.concatenate([np.linspace(25, 75, 401), np.linspace(75, 180, 401)])*u.MHz, 'times': start_time + np.linspace(0, (end_time-start_time).to_value('s'), 11003)*u.s } array = np.zeros((802, 11003)) parse_path_moc.return_value = [(array, meta)] file = Path('fakes.srs') spec = Spectrogram(file) assert isinstance(spec, RSTNSpectrogram) assert spec.observatory == 'SAN VITO' assert spec.instrument == 'RSTN' assert spec.detector == 'RSTN' assert spec.start_time.datetime == datetime(2020, 1, 1, 6, 17, 38) assert spec.end_time.datetime == datetime(2020, 1, 1, 15, 27, 43) assert spec.wavelength.min == 25000 * u.kHz assert spec.wavelength.max == 180000 * u.kHz
def test_get_url_for_time_range(LCClient, timerange, url_start, url_end): with mock.patch('sunpy.net.dataretriever.sources.norh.NoRHClient.search', return_value=mock_query_object(timerange)): qresponse = LCClient.search(timerange, a.Wavelength(17 * u.GHz)) assert isinstance(qresponse, QueryResponse) urls = [i['url'] for i in qresponse] assert urls[0] == url_start
def download(dtime, dt, dir_path, *args): """ Description: download fits files for specified time window and wavelength channels from the VSO dtime: should be a datetime object. EX: datetime(2010, 6, 13, 5, 25, 0) dt: should be a time delta object in correct units. EX: timedelta(seconds=6) dir_path: path to directory for storing fits files *argv: wavelength channels you want fits files for. EX: 193, 211, etc... """ sform = '%Y/%m/%d %H:%M:%S' # format datetime objects correctly start = datetime.strftime(dtime-dt, sform) end = datetime.strftime(dtime+dt, sform) time = attrs.Time(start, end) ins = attrs.Instrument('aia') for thing in args: print("Downloading {} angstrom data\n".format(thing)) wave = attrs.Wavelength(int(thing)*u.AA) searchResults = Fido.search(time, ins, wave) for file_ in searchResults: print("{}".format(file_)) dl_fil = Fido.fetch(searchResults, path=dir_path, wait=True)
def vso_attribute_parse(phrase): """ Parses VSO attributes from a HEK result. This is a simple function to parse HEK query result and generate a list containing VSO relevant attributes. Parameters ---------- phrase : `sunpy.net.hek.hek.HEKRow`. The single HEK result to be parsed for VSO attribute data. Examples -------- >>> from sunpy.net import attrs as a >>> from sunpy.net.hek import hek, HEKClient >>> from sunpy.net.hek2vso import hek2vso, H2VClient >>> h = HEKClient() # doctest: +REMOTE_DATA >>> h2v = H2VClient() # doctest: +REMOTE_DATA >>> q = h.search(a.Time('2011/08/09 07:23:56', '2011/08/09 12:40:29'), a.hek.EventType('FL')) # doctest: +REMOTE_DATA >>> len(q) # doctest: +REMOTE_DATA 19 >>> hek2vso.vso_attribute_parse(q[9]) # doctest: +REMOTE_DATA [<sunpy.net.attrs.Time(2011-08-09 07:22:38.000, 2011-08-09 08:32:02.000)>, <sunpy.net.attrs.Source(SDO: The Solar Dynamics Observatory.) object at ...>, <sunpy.net.attrs.Instrument(AIA: Atmospheric Imaging Assembly) object at ...>, <sunpy.net.attrs.Wavelength(210.99999999999997, 210.99999999999997, 'Angstrom')>] """ try: query = [a.Time(phrase['event_starttime'], phrase['event_endtime']), a.Source(phrase['obs_observatory']), a.Instrument(phrase['obs_instrument'])] avg_wave_len = phrase['obs_meanwavel'] * units.Unit(phrase['obs_wavelunit']) query.append(a.Wavelength(avg_wave_len, avg_wave_len)) except (KeyError, TypeError): raise TypeError("'{dtype!s}' is an improper data type".format(dtype=type(phrase))) return query
def dlSun(tlim: Union[list, ndarray] = [], instrument: str = 'aia', wl: int = 193, odir: str = '', first: bool = False): assert isinstance(tlim[0], str), 'time limits must be stings' tlim = array(tlim) if isinstance(tlim, list) else tlim assert tlim.shape[ 0] == 2, 'tlim must have length of 2 (start, stop) (yyyy/mm/dd hh:mm)' if odir == "": odir = os.path.join( 'C:\\Users\\smrak\\Google Drive\\BU\\Projects\\Eclipse-Nsf\\data\\', instrument, "") if not os.path.exists(odir): call('mkdir "{}"'.format(odir), shell=True) attrs_time = a.Time(tlim[0], tlim[1]) result = Fido.search(attrs_time, a.Instrument(instrument), a.Wavelength(wl * u.angstrom)) if first: print('Downloading to {}:'.format(odir)) print(result[0, 0]) Fido.fetch(result[0, 0], path=odir) else: print('Downloading {} elements.... to {}:'.format( result.file_num, odir)) print(result) Fido.fetch(result, path=odir) print('Downloading complete.')
def test_tables_all_types(): # Data retriver response objects drclient = Fido.search( a.Time('2012/3/4', '2012/3/6'), a.Instrument('lyra') | (a.Instrument('rhessi') & a.Physobs("summary_lightcurve"))) drtables = drclient.tables assert isinstance(drtables, list) assert isinstance(drtables[0], Table) # VSO response objects vsoclient = Fido.search(a.Time('2011-06-07 06:33', '2011-06-07 06:33:08'), a.Instrument('aia'), a.Wavelength(171 * u.AA)) vsotables = vsoclient.tables assert isinstance(vsotables, list) assert isinstance(vsotables[0], Table) # JSOC response objects jsocclient = Fido.search( a.Time('2014-01-01T00:00:00', '2014-01-01T01:00:00'), a.jsoc.Series('hmi.v_45s'), a.jsoc.Notify('*****@*****.**')) jsoctables = jsocclient.tables assert isinstance(jsoctables, list) assert isinstance(jsoctables[0], Table)
def test_fetch_working(suvi_client): """ Tests if the online server for fermi_gbm is working. This also checks if the mock is working well. """ start = '2019/05/25 00:50' end = '2019/05/25 00:52' wave = 94 * u.Angstrom qr1 = suvi_client.search(a.Time(start, end), a.Instrument.suvi, a.Wavelength(wave)) # Mock QueryResponse object mock_qr = mock_querry_object(suvi_client, start, end, wave) # Compare if two objects have the same attribute mock_qr = mock_qr.blocks[0] qr = qr1.blocks[0] assert mock_qr.source == qr.source assert mock_qr.provider == qr.provider assert mock_qr.physobs == qr.physobs assert mock_qr.instrument == qr.instrument assert mock_qr.url == qr.url assert qr1.time_range() == TimeRange("2019-05-25T00:52:00.000", "2019-05-25T00:56:00.000") with tempfile.TemporaryDirectory() as tmpdirname: download_list = suvi_client.fetch(qr1, path=tmpdirname) assert len(download_list) == len(qr1)
def test_fetch_working(suvi_client): """ Tests if the online server for goes_suvi is working. This also checks if the mock is working well. """ start = '2019/05/25 00:50' end = '2019/05/25 00:52' wave = 94 * u.Angstrom goes_sat = a.goes.SatelliteNumber.sixteen tr = a.Time(start, end) qr1 = suvi_client.search(tr, a.Instrument.suvi, a.Wavelength(wave), goes_sat, a.Level(2)) # Mock QueryResponse object mock_qr = mock_query_object(suvi_client) # Compare if two objects have the same attribute mock_qr = mock_qr[0] qr = qr1[0] assert mock_qr['Source'] == qr['Source'] assert mock_qr['Provider'] == qr['Provider'] assert mock_qr['Physobs'] == qr['Physobs'] assert mock_qr['Instrument'] == qr['Instrument'] assert mock_qr['url'] == qr['url'] assert qr1['Start Time'] == Time("2019-05-25T00:52:00.000") assert qr1['End Time'] == Time("2019-05-25T00:56:00.000") with tempfile.TemporaryDirectory() as tmpdirname: download_list = suvi_client.fetch(qr1, path=tmpdirname) assert len(download_list) == len(qr1)
def test_fido_waverange_level1b(start, end, wave1, wave2, expected_num_files): """check that we get all wavelengths if no wavelength is given""" goes_sat = a.goes.SatelliteNumber.sixteen result = Fido.search(a.Time(start, end), a.Instrument.suvi, goes_sat, a.Wavelength(wave1 * u.Angstrom, wave2 * u.Angstrom), a.Level('1b')) assert result.file_num == expected_num_files
def test_jsoc_cutout_attrs(client): m_ref = sunpy.map.Map( sunpy.data.test.get_test_filepath('aia_171_level1.fits')) cutout = a.jsoc.Cutout(SkyCoord(-500 * u.arcsec, -275 * u.arcsec, frame=m_ref.coordinate_frame), top_right=SkyCoord(150 * u.arcsec, 375 * u.arcsec, frame=m_ref.coordinate_frame), tracking=True) q = client.search( a.Time(m_ref.date, m_ref.date + 1 * u.min), a.Wavelength(171 * u.angstrom), a.jsoc.Series.aia_lev1_euv_12s, a.jsoc.Notify('*****@*****.**'), # Put your email here a.jsoc.Segment.image, cutout, ) req = client.request_data(q, method='url', protocol='fits') req.wait() assert req.status == 0 files = client.get_request(req, max_conn=2) assert len(files) == 6 m = sunpy.map.Map(files, sequence=True) assert m.all_maps_same_shape() assert m.as_array().shape == (1085, 1085, 6)
def test_psp_rfs_lfr(parse_path_moc): start_time = Time('2019-04-09 00:01:16.197889') end_time = Time('2019-04-10 00:01:04.997573') meta = { 'cdf_meta': { 'TITLE': 'PSP FIELDS RFS LFR data', 'Project': 'PSP', 'Source_name': 'PSP_FLD>Parker Solar Probe FIELDS', 'Descriptor': 'RFS_LFR>Radio Frequency Spectrometer LFR', 'Data_type': 'L2>Level 2 Data', 'Data_version': '01', 'MODS': 'Revision 1', 'Logical_file_id': 'psp_fld_l2_rfs_lfr_20190409_v01', 'Mission_group': 'PSP' }, 'detector': 'lfr', 'instrument': 'FIELDS/RFS', 'observatory': 'PSP', 'start_time': start_time, 'end_time': end_time, 'wavelength': a.Wavelength(10.546879882812501 * u.kHz, 1687.5 * u.kHz), 'times': start_time + np.linspace(0, (end_time - start_time).to_value('s'), 12359) * u.s, 'freqs': [ 10546.88, 18750., 28125., 37500., 46875., 56250., 65625., 75000., 84375., 89062.5, 94921.88, 100781.25, 106640.62, 112500., 118359.38, 125390.62, 132421.88, 140625., 146484.38, 157031.25, 166406.25, 175781.25, 186328.12, 196875., 208593.75, 220312.5, 233203.12, 247265.62, 261328.12, 276562.5, 292968.75, 309375., 328125., 346875., 366796.88, 387890.62, 411328.12, 434765.62, 459375., 486328.12, 514453.12, 544921.9, 576562.5, 609375., 645703.1, 682031.25, 721875., 764062.5, 808593.75, 855468.75, 904687.5, 957421.9, 1013671.9, 1072265.6, 1134375., 1196484.4, 1265625., 1312500., 1368750., 1425000., 1481250., 1565625., 1621875., 1687500. ] * u.Hz } array = np.zeros((64, 12359)) parse_path_moc.return_value = [(array, meta)] file = Path('fake.cdf') spec = Spectrogram(file) assert isinstance(spec, RFSSpectrogram) assert spec.observatory == 'PSP' assert spec.instrument == 'FIELDS/RFS' assert spec.detector == 'LFR' # TODO check why not exact prob base on spacecrast ET so won't match utc exacly assert spec.start_time.datetime == datetime(2019, 4, 9, 0, 1, 16, 197889) assert spec.end_time.datetime == datetime(2019, 4, 10, 0, 1, 4, 997573) assert spec.wavelength.min.round(1) == 10.5 * u.kHz assert spec.wavelength.max == 1687.5 * u.kHz assert spec.level == 'L2' assert spec.version == 1
def test_psp_rfs_hfr(parse_path_moc): start_time = Time('2019-04-09 00:01:13.904188') end_time = Time('2019-04-10 00:01:02.758315') meta = { 'cdf_meta': { 'TITLE': 'PSP FIELDS RFS HFR data', 'Project': 'PSP', 'Source_name': 'PSP_FLD>Parker Solar Probe FIELDS', 'Descriptor': 'RFS_HFR>Radio Frequency Spectrometer HFR', 'Data_type': 'L2>Level 2 Data', 'Data_version': '01', 'MODS': 'Revision 1', 'Logical_file_id': 'psp_fld_l2_rfs_lfr_20190409_v01', 'Mission_group': 'PSP' }, 'detector': 'hfr', 'instrument': 'FIELDS/RFS', 'observatory': 'PSP', 'start_time': start_time, 'end_time': end_time, 'wavelength': a.Wavelength(1275.0 * u.kHz, 19171.876 * u.kHz), 'times': start_time + np.linspace(0, (end_time - start_time).to_value('s'), 12359) * u.s, 'freqs': [ 1275000., 1321875., 1378125., 1425000., 1471875., 1575000., 1621875., 1678125., 1771875., 1828125., 1921875., 2025000., 2128125., 2221875., 2278125., 2371875., 2521875., 2625000., 2728125., 2878125., 2971875., 3121875., 3271875., 3375000., 3525000., 3721875., 3871875., 4021875., 4228125., 4425000., 4575000., 4771875., 5025000., 5221875., 5475000., 5728125., 5971875., 6225000., 6478125., 6778125., 7078125., 7425000., 7725000., 8071875., 8428125., 8821875., 9178125., 9571875., 10021875., 10471875., 10921875., 11428125., 11925000., 12421875., 13021875., 13575000., 14175000., 14821875., 15478125., 16125000., 16875000., 17625000., 18375000., 19171876. ] * u.Hz } array = np.zeros((64, 12359)) parse_path_moc.return_value = [(array, meta)] file = Path('fake.cdf') spec = Spectrogram(file) assert isinstance(spec, RFSSpectrogram) assert spec.observatory == 'PSP' assert spec.instrument == 'FIELDS/RFS' assert spec.detector == 'HFR' # TODO check why not exact prob base on spacecrast ET so won't match utc exacly assert spec.start_time.datetime == datetime(2019, 4, 9, 0, 1, 13, 904188) assert spec.end_time.datetime == datetime(2019, 4, 10, 0, 1, 2, 758315) assert spec.wavelength.min == 1275.0 * u.kHz assert spec.wavelength.max == 19171.876 * u.kHz assert spec.level == 'L2' assert spec.version == 1
def pre_search_hook(cls, *args, **kwargs): """ Converts the wavelength specified in the query to its representation in the url which can be used by the scraper. """ d = cls._get_match_dict(*args, **kwargs) waverange = a.Wavelength(34 * u.GHz, 17 * u.GHz) req_wave = d.get('Wavelength', waverange) wmin = req_wave.min.to(u.GHz, equivalencies=u.spectral()) wmax = req_wave.max.to(u.GHz, equivalencies=u.spectral()) req_wave = a.Wavelength(wmin, wmax) d['Wavelength'] = [] if 17 * u.GHz in req_wave: d['Wavelength'].append('tca') if 34 * u.GHz in req_wave: d['Wavelength'].append('tcz') return cls.baseurl, cls.pattern, d
def test_can_handle_query(LCClient, time): ans1 = LCClient._can_handle_query(time, a.Instrument.norh) assert ans1 is True ans1 = LCClient._can_handle_query(time, a.Instrument.norh, a.Wavelength(10 * u.GHz)) assert ans1 is True ans2 = LCClient._can_handle_query(time) assert ans2 is False
def test_search_metadata(client): with pytest.raises(SunpyDeprecationWarning): metadata = client.search_metadata(a.Time('2020-01-01T00:00:00', '2020-01-01T00:02:00'), a.jsoc.Series('aia.lev1_euv_12s'), a.Wavelength(304*u.AA)) assert isinstance(metadata, pd.DataFrame) assert metadata.shape == (11, 176) for i in metadata.index.values: assert (i.startswith('aia.lev1_euv_12s') and i.endswith('[304]'))
def test_can_handle_query(suvi_client, time): ans1 = suvi_client._can_handle_query(time, a.Instrument.suvi) assert ans1 is True ans2 = suvi_client._can_handle_query(time, a.Instrument.suvi, a.Wavelength(131 * u.Angstrom)) assert ans2 is True ans3 = suvi_client._can_handle_query(time, a.Instrument.suvi, a.Wavelength(131 * u.Angstrom), a.Level.two) assert ans3 is True ans4 = suvi_client._can_handle_query(time) assert ans4 is False ans5 = suvi_client._can_handle_query(time, a.Instrument.aia) assert ans5 is False ans6 = suvi_client._can_handle_query(time, a.Instrument.suvi, a.goes.SatelliteNumber(16)) assert ans6 is True
def test_response_block_properties(client): res = client.search(a.Time('2020/3/4', '2020/3/6'), a.Instrument('aia'), a.Wavelength(171 * u.angstrom), a.Sample(10 * u.minute), response_format="legacy") properties = res.response_block_properties() assert len(properties) == 0
def test_can_handle_query(time): ans1 = norh.NoRHClient._can_handle_query(time, a.Instrument('norh')) assert ans1 is True ans1 = norh.NoRHClient._can_handle_query(time, a.Instrument('norh'), a.Wavelength(10 * u.GHz)) assert ans1 is True ans2 = norh.NoRHClient._can_handle_query(time) assert ans2 is False
def online_query(draw, instrument=online_instruments()): query = draw(instrument) if isinstance(query, a.Instrument) and query.value == 'eve': query &= a.Level(0) if isinstance(query, a.Instrument) and query.value == 'norh': query &= a.Wavelength(17 * u.GHz) return query
def test_get_url_for_time_range_level2(suvi_client, start, end, wave, expected_num_files): goes_sat = a.goes.SatelliteNumber.sixteen qresponse = suvi_client.search(a.Time(start, end), a.Wavelength(wave * u.Angstrom), goes_sat, a.Level(2)) urls = [i['url'] for i in qresponse] assert isinstance(urls, list) assert len(urls) == expected_num_files
def test_vso_post_search(client): timerange = a.Time(('2020-01-01 00:01:05'), ('2020-01-01 00:01:10')) results = client.search(timerange, a.Instrument('aia') | a.Instrument('hmi')) trange_filter = a.Time(('2020-01-01 00:01:05'), ('2020-01-01 00:01:07')) wave_filter = a.Wavelength(131 * u.Angstrom) res_filtered = results.search(trange_filter & a.Instrument('aia') & wave_filter) for rec in res_filtered: assert parse_time(rec.time.start) <= parse_time(trange_filter.end) assert rec.instrument.lower() == 'aia' assert (float(rec.wave.wavemax) == 131.0 or float(rec.wave.wavemin) == 131.0)
def test_can_handle_query(time): # Don't use the fixture, as hypothesis complains suvi_client = goes.SUVIClient() ans1 = suvi_client._can_handle_query(time, a.Instrument.suvi) assert ans1 is True ans2 = suvi_client._can_handle_query(time, a.Instrument.suvi, a.Wavelength(131 * u.Angstrom)) assert ans2 is True ans3 = suvi_client._can_handle_query(time, a.Instrument.suvi, a.Wavelength(131 * u.Angstrom), a.Level.two) assert ans3 is True ans4 = suvi_client._can_handle_query(time) assert ans4 is False ans5 = suvi_client._can_handle_query(time, a.Instrument.aia) assert ans5 is False ans6 = suvi_client._can_handle_query(time, a.Instrument.suvi, a.goes.SatelliteNumber(16)) assert ans6 is True
def fido_search_result(): # A search query with responses from all instruments # No JSOC query return Fido.search( net_attrs.Time("2012/1/1", "2012/1/2"), net_attrs.Instrument('lyra') | net_attrs.Instrument('eve') | net_attrs.Instrument('XRS') | net_attrs.Instrument('noaa-indices') | net_attrs.Instrument('noaa-predict') | (net_attrs.Instrument('norh') & net_attrs.Wavelength(17 * u.GHz)) | net_attrs.Instrument('rhessi') | (net_attrs.Instrument('EVE') & net_attrs.Level(0)))