def test_display_entries(): entries = [ DatabaseEntry( id=1, source='SOHO', provider='SDAC', physobs='intensity', fileid='/archive/soho/...', observation_time_start=datetime(2001, 1, 1, 7, 0, 14), observation_time_end=datetime(2001, 1, 1, 7, 0, 21), instrument='EIT', size=259.0, wavemin=171.0, wavemax=171.0, tags=[Tag('foo'), Tag('bar')]), DatabaseEntry( id=2, source='GONG', provider='NSO', physobs='LOS_velocity', fileid='pptid=11010...', observation_time_start=datetime(2010, 1, 1, 0, 59), observation_time_end=datetime(2010, 1, 1, 1), download_time=datetime(2014, 6, 15, 3, 42, 55, 123456), instrument='Merged gong', size=944.0, wavemin=6768.0, wavemax=6768.0, starred=True)] columns = [ 'id', 'source', 'provider', 'physobs', 'fileid', 'download_time', 'observation_time_start', 'instrument', 'size', 'wavemin', 'path', 'starred', 'tags'] table = display_entries(entries, columns) filedir = os.path.dirname(os.path.realpath(__file__)) with open(os.path.join(filedir,'test_table.txt'), 'r') as f: stored_table = f.read() assert table.strip() == stored_table.strip()
def test_display_entries(): entries = [ DatabaseEntry( id=1, source="SOHO", provider="SDAC", physobs="intensity", fileid="/archive/soho/...", observation_time_start=datetime(2001, 1, 1, 7, 0, 14), observation_time_end=datetime(2001, 1, 1, 7, 0, 21), instrument="EIT", size=259.0, wavemin=171.0, wavemax=171.0, tags=[Tag("foo"), Tag("bar")], ), DatabaseEntry( id=2, source="GONG", provider="NSO", physobs="LOS_velocity", fileid="pptid=11010...", observation_time_start=datetime(2010, 1, 1, 0, 59), observation_time_end=datetime(2010, 1, 1, 1), download_time=datetime(2014, 6, 15, 3, 42, 55, 123456), instrument="Merged gong", size=944.0, wavemin=6768.0, wavemax=6768.0, starred=True, ), ] columns = [ "id", "source", "provider", "physobs", "fileid", "download_time", "observation_time_start", "instrument", "size", "wavemin", "path", "starred", "tags", ] table = display_entries(entries, columns) filedir = os.path.dirname(os.path.realpath(__file__)) with open(os.path.join(filedir, "test_table.txt"), "r") as f: stored_table = f.read() assert table.strip() == stored_table.strip()
def test_display_entries(): entries = [ DatabaseEntry( id=1, source='SOHO', provider='SDAC', physobs='intensity', fileid='/archive/soho/...', observation_time_start=datetime(2001, 1, 1, 7, 0, 14), observation_time_end=datetime(2001, 1, 1, 7, 0, 21), instrument='EIT', size=259.0, wavemin=171.0, wavemax=171.0, tags=[Tag('foo'), Tag('bar')]), DatabaseEntry( id=2, source='GONG', provider='NSO', physobs='LOS_velocity', fileid='pptid=11010...', observation_time_start=datetime(2010, 1, 1, 0, 59), observation_time_end=datetime(2010, 1, 1, 1), instrument='Merged gong', size=944.0, wavemin=6768.0, wavemax=6768.0, starred=True)] columns = [ 'id', 'source', 'provider', 'physobs', 'fileid', 'observation_time_start', 'observation_time_end', 'instrument', 'size', 'wavemin', 'path', 'starred', 'tags'] table = display_entries(entries, columns) assert table == """id source provider physobs fileid observation_time_start observation_time_end instrument size wavemin path starred tags
def test_display_entries_missing_columns(): with pytest.raises(TypeError): display_entries([DatabaseEntry()], [])
def test_display_entries_empty_db(): with pytest.raises(TypeError): display_entries(Database('sqlite:///'), ['id'])
def test_display_entries_missing_entries(): with pytest.raises(TypeError): display_entries([], ['some', 'columns'])
from sunpy.net import vso from sunpy.database import Database database = Database("sqlite:///") database.download(vso.attrs.Time("2012-08-05", "2012-08-05 00:00:05"), vso.attrs.Instrument('AIA')) len(database) from sunpy.database.tables import display_entries print display_entries(database, ["id", "observation_time_start", "wavemin", "wavemax"])
def test_display_entries_empty_db(): with pytest.raises(TypeError): display_entries(Database("sqlite:///"), ["id"])
def test_display_entries_missing_entries(): with pytest.raises(TypeError): display_entries([], ["some", "columns"])
from sunpy.net import vso from sunpy.database import Database database = Database("sqlite:///") database.download( vso.attrs.Time("2012-08-05", "2012-08-05 00:00:05"), vso.attrs.Instrument('AIA')) len(database) from sunpy.database.tables import display_entries print display_entries( database, ["id", "observation_time_start", "wavemin", "wavemax"])
download = Fido.fetch(result,path="./data/") # Now the data is downloaded you should see a folder called data with a bunch of fits files inside. # FITS stands for Flexible Interchangeable Transport System. It is the de facto image format for astronomy. # The image contains a "header" which contains information about the image. # HMI images have been downloaded for you and are already in the folder (using the online search form https://vso.nascom.nasa.gov/cgi-bin/search). # Let's add the fits in our folder to the database. db.add_from_dir("./data/", ignore_already_added=True,time_string_parse_format="%d/%m/%Y") # Let's see what's now in our database: for database_entry in db: if database_entry.observation_time_start is None and database_entry.observation_time_end is None: db.remove(database_entry) print(display_entries(db,['id', 'observation_time_start','instrument', 'wavemin'])) # We can now search the database. Here we are searching for images in wavelengths between 1-2 nm or 10-20 Angstrom. # We have also chosen to sort our results by wavlength! print(display_entries(db.search(a.Wavelength(1.0*u.nm, 2.0*u.nm)),['id', 'observation_time_start', 'instrument', 'wavemin'], sort=True)) # Another way to fetch data is to use: # entries = db.fetch(a.Time('2019/05/06 12:00', '2019/05/06 12:01'),a.Instrument('aia'),a.vso.Sample(2*u.minute),a.Wavelength(94*u.angstrom)) # This automatically adds the observations to our database and downloads files checking for duplicates. # Now we have our images let's plot them! AIA = db.search(a.Wavelength(.1*u.nm, 60.0*u.nm)) AIAplotDic = {} for obs in AIA: