Esempio n. 1
0
 def test_request(self, mock_get):
     x, y = ("2010-06-01T00:00:00", "2010-07-01T00:00:00")
     hek = Hek_Service(event_starttime=x, event_endtime=y)
     hek.submit_request()
     self.assertEqual(len(hek.data), 8)
     event1 = hek.data[0]
     self.assertEqual(event1.sol_standard, "SOL2010-06-04T09:21:47L246C049")
Esempio n. 2
0
    def test_save_request(self):
        base = datetime.today()
        total = 1
        date_list = [base - timedelta(days=120 * x) for x in range(total)]
        requests = [
            Hek_Service(
                event_starttime=x.strftime(Config.time_format.hek),
                event_endtime=y.strftime(Config.time_format.hek),
            )
            for x in date_list
            for y in date_list
        ]
        for x in requests:
            x.save_request()
        self.assertEqual(
            Service_Request.select().where(Service_Request.service_type == "hek"),
            total * total,
        )

        for x in requests:
            x.save_request()
        self.assertEqual(
            Service_Request.select().where(Service_Request.service_type == "hek"),
            total * total,
        )

        for x, y in zip(
            requests,
            Service_Request.select().where(Service_Request.service_type == "hek"),
        ):
            self.assertEqual(x.start_time, y["event_starttime"])
Esempio n. 3
0
 def test_kwargs(self):
     param_dict = dict(
         param1=1, param2=1.1, param3="hello", param4=["x", "y"], param5=[1, 2, 3]
     )
     hek = Hek_Service(**param_dict)
     for x in param_dict:
         self.assertEqual(hek[x], param_dict[x])
def parse_hek_exist(search, action, save_data=False, save_request=False):
    hek = Service_Request.select().where(
        (Service_Request.service_type == "hek")
        & ((Service_Request.id % search) | (Service_Request.job_id % f"%{search}%"))
    )
    if not hek:
        print("Could not find any requests matching the search")
        return None
    elif len(hek) > 1:
        print("I found too many requests with this search, please try to narrow it")
        for x in hek:
            print(x)
        return None
    h = Hek_Service._from_model(hek.get())
    print("I will use the request")
    print(h)
    grab_save(h, action, save_data, save_request)
Esempio n. 5
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)
Esempio n. 6
0
from solar.service.hek import Hek_Service
from solar.service.cutout import Cutout_Service, multi_cutout
from solar.database.tables.fits_file import Fits_File
from solar.database.tables.visual_file import Visual_File
from solar.visual.img import Basic_Image
from solar.visual.vid import Basic_Video
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)
def parse_hek_params(param_dict, action, save_data=False, save_request=False):
    h = Hek_Service(**param_dict)
    grab_save(h, action, save_data, save_request)
Esempio n. 8
0
from solar.database.tables.hek_event import Hek_Event
from solar.service.cutout import Cutout_Service, multi_cutout
from solar.database.tables.fits_file import Fits_File
from solar.database.tables.visual_file import Visual_File
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")
from solar.service.hek import Hek_Service
from solar.service.cutout import Cutout_Service, multi_cutout
from solar.database.tables.fits_file import Fits_File
from solar.database.tables.visual_file import Visual_File
from solar.visual.img import Basic_Image
from solar.visual.vid import Basic_Video
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="2015-10-01T00:00:00",
    event_endtime="2015-11-15T00:00: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

# 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.
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