コード例 #1
0
    def test_save_requests(self):
        h = Hek_Service()
        events = [
            Hek_Event(event_id="1"),
            Hek_Event(event_id="123123"),
            Hek_Event(event_id="12031mmjdd"),
            Hek_Event(event_id="asdfnadfsoos"),
        ]

        h._data = events
        self.assertEqual(len(h._data), 4)

        h.save_data()
        self.assertEqual(len(Hek_Event.select()), 4)

        for x, y in zip(events, Hek_Event.select()):
            self.assertEqual(x.event_id, y.event_id)

        h.save_data()
        self.assertEqual(len(Hek_Event.select()), 4)

        for x, y in zip(events, Hek_Event.select()):
            self.assertEqual(x.event_id, y.event_id)
コード例 #2
0
from solar.database import create_tables

create_tables()

# Let us prepare a request for the hek service where we search for all coronal jets that occured between the October 1, 2015 and November 15, 2015.
hek = Hek_Service(
    event_starttime="2012-03-08T21:15:00",
    event_endtime="2012-03-08T22:15:00",
    event_type=["cj"],
)

# Now that request is prepared we can submit it.
hek.submit_request()

# The list of events found by the search are stored in the data member variable
hek.save_data()
events = hek.data
# To save the events to the database, we iterate over the events, and catch when we try to insert an even that already exists in the database

cutout_reqs = [Cutout_Service._from_event(event) for event in events]

# We use the helper function multi_cutout to make the requests asynchronously. The cutouts are saved
# Warning: this can take a very long time
completed_requests = multi_cutout(cutout_reqs)

for individual_req in completed_requests:
    individual_req.save_data()

# At this point we have a bunch of references to files in the SSW database.
# To actually download the files and extract header data, we need to update the Fits_File table
コード例 #3
0
from solar.database.tables.join_vis_fit import Join_Visual_Fits
from solar.visual.img import Basic_Image
from solar.visual.vid import Basic_Video
from solar.database import create_tables
from solar.zooniverse.export import zooniverse_export, prepare_row, split

create_tables()

# Let us prepare a request for the hek service where we search for all coronal jets that occured between the October 1, 2015 and November 15, 2015.

if True:
    h = Hek_Service(event_starttime="2010-06-01T00:00:00",
                    event_endtime="2010-9-30T00:00:00")
    h.submit_request()
    h.save_request()
    h.save_data()
    # Now that request is prepared we can submit it.

    # The list of events found by the search are stored in the data member variable

    # To save the events to the database, we iterate over the events, and catch when we try to insert an even that already exists in the database

    # Now let us get the fits files that correspond to these events
    # Please see http://docs.peewee-orm.com/en/latest/peewee/api.html# for information on constructing queries.
    c = [Cutout_Service._from_event(h) for h in Hek_Event.select()]
    multi_cutout(c)

bi = Basic_Image("png")

for x in Fits_File.select().where(Fits_File.event == 2):
    Visual_File.create_new_visual(x, bi).save()