def _onDownloadResult(self, paths, f_id, request): path = self._unzipResult(paths[0]) entry = list(tables.entries_from_fido_search_result(request, self.database.default_waveunit))[0] entry.path = path self.database.add(entry) self.database.commit() self._addLoaded({f_id: path})
def test_entries_from_fido_search_result_JSOC(): search_result = Fido.search( net_attrs.Time('2014-01-01T00:00:00', '2014-01-01T01:00:00'), net_attrs.jsoc.Series('hmi.m_45s'), net_attrs.jsoc.Notify("*****@*****.**")) with pytest.raises(ValueError): # Using list() here is important because the # entries_from_fido_search_result function uses yield. # list() uses the generator to run the function body. list(entries_from_fido_search_result(search_result))
def test_entries_from_fido_search_result_JSOC(): search_result = Fido.search( net_attrs.jsoc.Time('2014-01-01T00:00:00', '2014-01-01T01:00:00'), net_attrs.jsoc.Series('hmi.m_45s'), net_attrs.jsoc.Notify("*****@*****.**") ) with pytest.raises(ValueError): # Using list() here is important because the # entries_from_fido_search_result function uses yield. # list() uses the generator to run the function body. list(entries_from_fido_search_result(search_result))
def add_from_fido_search_result(self, search_result, ignore_already_added=False): """ Generate database entries from a Fido search result and add all the generated entries to this database. Parameters ---------- search_result : `sunpy.net.fido_factory.UnifiedResponse` A UnifiedResponse object that is used to store responses from the unified downloader. This is returned by the ``search`` method of a :class:`sunpy.net.fido_factory.UnifiedDownloaderFactory` object. ignore_already_added : `bool` See :meth:`sunpy.database.Database.add`. """ self.add_many(tables.entries_from_fido_search_result(search_result, self.default_waveunit), ignore_already_added)
def test_entries_from_fido_search_result(fido_search_result): entries = list(entries_from_fido_search_result(fido_search_result)) # 66 entries for 8 instruments in fido_search_result assert len(entries) == 66 # First 2 entries are from lyra assert entries[0] == DatabaseEntry( source='Proba2', provider='esa', physobs='irradiance', fileid= 'http://proba2.oma.be/lyra/data/bsd/2012/01/01/lyra_20120101-000000_lev2_std.fits', observation_time_start=datetime(2012, 1, 1, 0, 0), observation_time_end=datetime(2012, 1, 2, 0, 0), wavemin=np.nan, wavemax=np.nan, instrument='lyra') # 54 entries from EVE assert entries[2] == DatabaseEntry( source='SDO', provider='LASP', physobs='irradiance', fileid='EVE_L1_esp_2012001_00', observation_time_start=datetime(2012, 1, 1, 0, 0), observation_time_end=datetime(2012, 1, 2, 0, 0), instrument='EVE', wavemin=0.1, wavemax=30.4) # 2 entries from goes assert entries[56] == DatabaseEntry( source='nasa', provider='sdac', physobs='irradiance', fileid='https://umbra.nascom.nasa.gov/goes/fits/2012/go1520120101.fits', observation_time_start=datetime(2012, 1, 1, 0, 0), observation_time_end=datetime(2012, 1, 1, 23, 59, 59, 999000), wavemin=np.nan, wavemax=np.nan, instrument='goes') # 1 entry from noaa-indices assert entries[58] == DatabaseEntry( source='sdic', provider='swpc', physobs='sunspot number', fileid='ftp://ftp.swpc.noaa.gov/pub/weekly/RecentIndices.txt', observation_time_start=datetime(2012, 1, 1, 0, 0), observation_time_end=datetime(2012, 1, 2, 0, 0), wavemin=np.nan, wavemax=np.nan, instrument='noaa-indices') # 1 entry from noaa-predict assert entries[59] == DatabaseEntry( source='ises', provider='swpc', physobs='sunspot number', fileid= 'http://services.swpc.noaa.gov/text/predicted-sunspot-radio-flux.txt', observation_time_start=datetime(2012, 1, 1, 0, 0), observation_time_end=datetime(2012, 1, 2, 0, 0), wavemin=np.nan, wavemax=np.nan, instrument='noaa-predict') # 2 entries from norh assert entries[60] == DatabaseEntry( source='NAOJ', provider='NRO', physobs="", fileid=("ftp://*****:*****@[email protected]/" "pub/nsro/norh/data/tcx/2012/01/tca120101"), observation_time_start=datetime(2012, 1, 1, 0, 0), observation_time_end=datetime(2012, 1, 2, 0, 0), wavemin=17634850.470588233, wavemax=17634850.470588233, instrument='NORH') # 1 entry from rhessi assert entries[62] == DatabaseEntry( source="rhessi", provider='nasa', physobs='irradiance', fileid=("https://hesperia.gsfc.nasa.gov/" "hessidata/metadata/catalog/hsi_obssumm_20120101_016.fits"), observation_time_start=datetime(2012, 1, 1, 0, 0), observation_time_end=datetime(2012, 1, 1, 23, 59, 59, 999000), wavemin=np.nan, wavemax=np.nan, instrument='rhessi') # 2 entries from eve, level 0 assert entries[64] == DatabaseEntry( source='SDO', provider='LASP', physobs='irradiance', fileid=("http://lasp.colorado.edu/eve/data_access/evewebdata/quicklook" "/L0CS/SpWx/2012/20120101_EVE_L0CS_DIODES_1m.txt"), observation_time_start=datetime(2012, 1, 1, 0, 0), observation_time_end=datetime(2012, 1, 2, 0, 0), wavemin=np.nan, wavemax=np.nan, instrument='eve')
def test_entries_from_fido_search_result(fido_search_result): entries = list(entries_from_fido_search_result(fido_search_result)) # 65 entries for 8 instruments in fido_search_result assert len(entries) == 65 # First 2 entries are from lyra assert entries[0] == DatabaseEntry( source='Proba2', provider='esa', physobs='irradiance', fileid='http://proba2.oma.be/lyra/data/bsd/2012/01/01/lyra_20120101-000000_lev2_std.fits', observation_time_start=datetime(2012, 1, 1, 0, 0), observation_time_end=datetime(2012, 1, 2, 0, 0), wavemin=np.nan, wavemax=np.nan, instrument='lyra') # 54 entries from EVE assert entries[2] == DatabaseEntry( source='SDO', provider='LASP', physobs='irradiance', fileid='EVE_L1_esp_2012001_00', observation_time_start=datetime(2012, 1, 1, 0, 0), observation_time_end=datetime(2012, 1, 2, 0, 0), instrument='EVE', size=-1.0, wavemin=0.1, wavemax=30.4) # 2 entries from goes assert entries[56] == DatabaseEntry( source='nasa', provider='sdac', physobs='irradiance', fileid='https://umbra.nascom.nasa.gov/goes/fits/2012/go1520120101.fits', observation_time_start=datetime(2012, 1, 1, 0, 0), observation_time_end=datetime(2012, 1, 1, 23, 59, 59, 999000), wavemin=np.nan, wavemax=np.nan, instrument='goes') # 1 entry from noaa-indices assert entries[58] == DatabaseEntry( source='sdic', provider='swpc', physobs='sunspot number', fileid='ftp://ftp.swpc.noaa.gov/pub/weekly/RecentIndices.txt', observation_time_start=datetime(2012, 1, 1, 0, 0), observation_time_end=datetime(2012, 1, 2, 0, 0), wavemin=np.nan, wavemax=np.nan, instrument='noaa-indices') # 1 entry from noaa-predict assert entries[59] == DatabaseEntry( source='ises', provider='swpc', physobs='sunspot number', fileid='http://services.swpc.noaa.gov/text/predicted-sunspot-radio-flux.txt', observation_time_start=datetime(2012, 1, 1, 0, 0), observation_time_end=datetime(2012, 1, 2, 0, 0), wavemin=np.nan, wavemax=np.nan, instrument='noaa-predict') # 2 entries from norh assert entries[60] == DatabaseEntry( source='NAOJ', provider='NRO', physobs="", fileid=("ftp://*****:*****@[email protected]/" "pub/nsro/norh/data/tcx/2012/01/tca120101"), observation_time_start=datetime(2012, 1, 1, 0, 0), observation_time_end=datetime(2012, 1, 2, 0, 0), wavemin=17634850.470588233, wavemax=17634850.470588233, instrument='NORH') # 1 entry from rhessi assert entries[62] == DatabaseEntry( source="rhessi", provider='nasa', physobs='irradiance', fileid=("https://hesperia.gsfc.nasa.gov/" "hessidata/metadata/catalog/hsi_obssumm_20120101_016.fits"), observation_time_start=datetime(2012, 1, 1, 0, 0), observation_time_end=datetime(2012, 1, 2, 0, 0), wavemin=np.nan, wavemax=np.nan, instrument='rhessi') # 2 entries from eve, level 0 assert entries[63] == DatabaseEntry( source='SDO', provider='LASP', physobs='irradiance', fileid=("http://lasp.colorado.edu/eve/data_access/evewebdata/quicklook" "/L0CS/SpWx/2012/20120101_EVE_L0CS_DIODES_1m.txt"), observation_time_start=datetime(2012, 1, 1, 0, 0), observation_time_end=datetime(2012, 1, 2, 0, 0), wavemin=np.nan, wavemax=np.nan, instrument='eve')
def test_entries_from_fido_search_result(fido_search_result): entries = list(entries_from_fido_search_result(fido_search_result)) # 66 entries for 8 instruments in fido_search_result assert len(entries) == 66 # First 2 entries are from lyra assert entries[0] == DatabaseEntry( source='PROBA2', provider='ESA', physobs='irradiance', fileid= 'http://proba2.oma.be/lyra/data/bsd/2012/01/01/lyra_20120101-000000_lev2_std.fits', observation_time_start=datetime(2012, 1, 1, 0, 0), observation_time_end=datetime(2012, 1, 1, 23, 59, 59, 999000), wavemin=np.nan, wavemax=np.nan, instrument='LYRA') # 2 entries from eve, level 0 assert entries[2] == DatabaseEntry( source='SDO', provider='LASP', physobs='irradiance', fileid=("http://lasp.colorado.edu/eve/data_access/evewebdata/quicklook" "/L0CS/SpWx/2012/20120101_EVE_L0CS_DIODES_1m.txt"), observation_time_start=datetime(2012, 1, 1, 0, 0), observation_time_end=datetime(2012, 1, 1, 23, 59, 59, 999000), wavemin=np.nan, wavemax=np.nan, instrument='EVE') # 54 entries from EVE assert entries[4] == DatabaseEntry( source='SDO', provider='LASP', physobs='irradiance', fileid='EVE_L1_esp_2012001_00', observation_time_start=datetime(2012, 1, 1, 0, 0), observation_time_end=datetime(2012, 1, 2, 0, 0), size=None, instrument='EVE', wavemin=0.1, wavemax=30.4) # 2 entries from goes assert entries[58] == DatabaseEntry( source='GOES', provider='NOAA', physobs='irradiance', fileid='https://satdat.ngdc.noaa.gov/sem/goes/data/science/xrs/goes15/' 'gxrs-l2-irrad_science/2012/01/sci_gxrs-l2-irrad_g15_d20120101_v0-0-0.nc', observation_time_start=datetime(2012, 1, 1, 0, 0), observation_time_end=datetime(2012, 1, 1, 23, 59, 59, 999000), wavemin=np.nan, wavemax=np.nan, instrument='XRS') # 1 entry from noaa-indices assert entries[60] == DatabaseEntry( source='SIDC', provider='SWPC', physobs='sunspot number', fileid= 'https://services.swpc.noaa.gov/json/solar-cycle/observed-solar-cycle-indices.json', observation_time_start=None, observation_time_end=None, wavemin=np.nan, wavemax=np.nan, instrument='NOAA-Indices') # 1 entry from noaa-predict assert entries[61] == DatabaseEntry( source='ISES', provider='SWPC', physobs='sunspot number', fileid= 'https://services.swpc.noaa.gov/json/solar-cycle/predicted-solar-cycle.json', observation_time_start=None, observation_time_end=None, wavemin=np.nan, wavemax=np.nan, instrument='NOAA-Predict') # 2 entries from norh assert entries[62] == DatabaseEntry( source='NAOJ', provider='NRO', physobs=None, fileid=("ftp://solar-pub.nao.ac.jp/" "pub/nsro/norh/data/tcx/2012/01/tca120101"), observation_time_start=datetime(2012, 1, 1, 0, 0), observation_time_end=datetime(2012, 1, 1, 23, 59, 59, 999000), wavemin=17634850.470588233, wavemax=17634850.470588233, instrument='NORH') # 1 entry from rhessi assert entries[64] == DatabaseEntry( source="RHESSI", provider='NASA', physobs='summary_lightcurve', fileid=("https://hesperia.gsfc.nasa.gov/" "hessidata/metadata/catalog/hsi_obssumm_20120101_032.fits"), observation_time_start=datetime(2012, 1, 1, 0, 0), observation_time_end=datetime(2012, 1, 1, 23, 59, 59, 999000), wavemin=np.nan, wavemax=np.nan, instrument='RHESSI')