Esempio n. 1
0
def mock_query_object(LCClient):
    """
    Creating a Query Response object and prefilling it with some information
    """
    # Creating a Query Response Object
    start = '2016/1/1'
    end = '2016/1/1 23:59:59'
    obj = {
        'Start Time':
        parse_time(start),
        'End Time':
        parse_time(end),
        'Instrument':
        'EVE',
        'Physobs':
        'irradiance',
        'Source':
        'SDO',
        'Provider':
        'LASP',
        'Level':
        '0',
        'url': ('http://lasp.colorado.edu/eve/data_access/evewebdata/'
                'quicklook/L0CS/SpWx/2016/20160101_EVE_L0CS_DIODES_1m.txt')
    }
    results = QueryResponse([obj], client=LCClient)
    return results
Esempio n. 2
0
def mock_query_object(timerange):
    """
    Creating a Query Response object and prefilling it with some information
    """
    # Creating a Query Response Object
    start = timerange.start
    end = timerange.end
    wave = 17 * u.GHz
    delta = end - start
    resp = []
    for i in range(delta.datetime.days + 1):
        start_time = start.datetime + timedelta(days=i)
        end_time = start_time + timedelta(days=1) - timedelta(milliseconds=1)
        obj = {
            'Start Time': parse_time(start_time),
            'End Time': parse_time(end_time),
            'Instrument': 'NORH',
            'Source': 'NAOJ',
            'Provider': 'NRO',
            'Wavelength': wave,
            'url': create_url(start_time, wave)
        }
        resp.append(obj)
    results = QueryResponse(resp, client=norh.NoRHClient())
    return results
Esempio n. 3
0
def mock_query_object(start_date, end_date):
    """
    Creation of a QueryResponse object, and prefill some
    downloaded data from noaa.NOAAIndicesClient().fetch(Time('20 ..)
    """
    # Create a mock Query Response object
    start = parse_time(start_date)
    end = parse_time(end_date)
    obj = {
        'Start Time':
        parse_time(start),
        'End Time':
        parse_time(end),
        'Instrument':
        'NOAA-Indices',
        'Physobs':
        'sunspot number',
        'Source':
        'SIDC',
        'Provider':
        'SWPC',
        'url':
        'https://services.swpc.noaa.gov/json/solar-cycle/observed-solar-cycle-indices.json'
    }
    results = QueryResponse([obj], client=noaa.NOAAIndicesClient())
    return results
Esempio n. 4
0
def test_time_range():
    rows = [{'Start Time': parse_time("2020/01/01"), 'End Time': parse_time("2020/01/02")},
            {'Start Time': parse_time("2019/01/01"), 'End Time': parse_time("2019/01/02")}]
    resp = QueryResponse(rows)

    assert resp.time_range().start == parse_time("2019/01/01")
    assert resp.time_range().end == parse_time("2020/01/02")
Esempio n. 5
0
def mock_query_object(suvi_client):
    """
    Creating a Query Response object and prefilling it with some information
    """
    # Creating a Query Response Object
    start = '2019/05/25 00:50'
    end = '2019/05/25 00:52'
    wave = 94 * u.Angstrom
    obj = {
        'Start Time':
        parse_time(start),
        'End Time':
        parse_time(end),
        'Instrument':
        'SUVI',
        'Physobs':
        'flux',
        'Source':
        'GOES',
        'Provider':
        'NOAA',
        'Level':
        '2',
        'Wavelength':
        wave,
        'url':
        ('https://data.ngdc.noaa.gov/platforms/solar-space-observing-satellites'
         '/goes/goes16/l2/data/suvi-l2-ci094/2019/05/25/'
         'dr_suvi-l2-ci094_g16_s20190525T005200Z_e20190525T005600Z_v1-0-0.fits'
         )
    }
    results = QueryResponse([obj], client=suvi_client)
    return results
Esempio n. 6
0
def mock_query_object(LCClient):
    """
    Creating a Query Response object and prefilling it with some information
    """
    # Creating a Query Response Object
    start = '2016/1/1'
    end = '2016/1/1 23:59:59'
    obj = {
        'Start Time':
        parse_time(start),
        'End Time':
        parse_time(end),
        'Instrument':
        'GBM',
        'Physobs':
        'flux',
        'Source':
        'FERMI',
        'Provider':
        'NASA',
        'Resolution':
        'cspec',
        'Detector':
        'n5',
        'url': ('https://heasarc.gsfc.nasa.gov/FTP/fermi/data/gbm/daily/'
                '2016/01/01/current/glg_cspec_n5_160101_v00.pha')
    }
    results = QueryResponse([obj], client=LCClient)
    return results
Esempio n. 7
0
def mock_query_object(LCClient):
    """
    Creating a Query Response object and prefilling it with some information
    """
    # Creating a Query Response Object
    start = '2016/1/1'
    end = '2016/1/1 23:59:59'
    obj = {
        'Start Time':
        parse_time(start),
        'End Time':
        parse_time(end),
        'Instrument':
        'LYRA',
        'Physobs':
        'irradiance',
        'Source':
        'PROBA2',
        'Provider':
        'ESA',
        'Level':
        '2',
        'url': ('http://proba2.oma.be/lyra/data/bsd/2016/01/01/'
                'lyra_20160101-000000_lev2_std.fits')
    }
    results = QueryResponse([obj], client=LCClient)
    return results
Esempio n. 8
0
def mock_query_object(LCClient):
    """
    Creating a Query Response object and prefilling it with some information
    """
    # Creating a Query Response Object
    start = '2016/1/1'
    end = '2016/1/1 23:59:59'
    obj = {
        'Start Time':
        parse_time(start),
        'End Time':
        parse_time(end),
        'Instrument':
        'RHESSI',
        'Physobs':
        'irradiance',
        'Source':
        'RHESSI',
        'Provider':
        'NASA',
        'url': ('https://hesperia.gsfc.nasa.gov/hessidata/metadata/'
                'catalog/hsi_obssumm_20160101_078.fits')
    }
    results = QueryResponse([obj], client=LCClient)
    return results
Esempio n. 9
0
def test_reprs():
    rowdict = {}
    rowdict['Start Time'] = parse_time("2012/1/1")
    rowdict['End Time'] = parse_time("2012/1/2")
    resp = QueryResponse([rowdict])
    assert isinstance(resp, QueryResponse)
    strs = ["2012-01-01T00:00:00.000", "2012-01-02T00:00:00.000"]
    assert all(s in str(resp) for s in strs)
    assert all(s in repr(resp) for s in strs)
Esempio n. 10
0
    def search(self, *args, **kwargs):
        baseurl, pattern, matchdict = self.pre_search_hook(*args, **kwargs)
        metalist = []
        for obs in matchdict['Observatory']:
            scraper = Scraper(baseurl.format(obs=self.observatory_map[obs.title()]), regex=True)
            tr = TimeRange(matchdict['Start Time'], matchdict['End Time'])
            filesmeta = scraper._extract_files_meta(tr, extractor=pattern,
                                                    matcher=matchdict)

            for i in filesmeta:
                rowdict = self.post_search_hook(i, matchdict)
                metalist.append(rowdict)

        return QueryResponse(metalist, client=self)
Esempio n. 11
0
def mock_query_object(LCClient):
    """
    Creating a Query Response object and prefilling it with some information
    """
    # Creating a Query Response Object
    start = '2016/1/1'
    end = '2016/1/1 23:59:59'
    obj = {
        'Start Time': parse_time(start),
        'End Time': parse_time(end),
        'Instrument': 'GOES',
        'Physobs': 'irradiance',
        'Source': 'GOES',
        'Provider': 'NOAA',
        'SatelliteNumber': '15',
        'url': 'https://umbra.nascom.nasa.gov/goes/fits/2016/go1520160101.fits'
    }
    results = QueryResponse([obj], client=LCClient)
    return results
Esempio n. 12
0
def mock_query_object(LCClient):
    """
    Creating a Query Response object and prefilling it with some information
    """
    # Creating a Query Response Object
    start = '2016/1/1'
    end = '2016/1/1 23:59:59'
    wave = 17 * u.GHz
    obj = {
        'Start Time': parse_time(start),
        'End Time': parse_time(end),
        'Instrument': 'NORH',
        'Source': 'NAOJ',
        'Provider': 'NRO',
        'Wavelength': wave,
        'url':
        'ftp://solar-pub.nao.ac.jp/pub/nsro/norh/data/tcx/2016/01/tca160101'
    }
    results = QueryResponse([obj], client=LCClient)
    return results
Esempio n. 13
0
    def search(self, *args, **kwargs):
        """
        Query this client for a list of results.

        Parameters
        ----------
        *args: `tuple`
            `sunpy.net.attrs` objects representing the query.
        **kwargs: `dict`
            Any extra keywords to refine the search.

        Returns
        -------
        A `QueryResponse` instance containing the query result.
        """
        matchdict = self._get_match_dict(*args, **kwargs)
        req_wave = matchdict.get('Wavelength', None)
        receivers = RECEIVER_FREQUENCIES.keys()
        if req_wave is not None:
            receivers = self._check_wavelengths(req_wave)

        metalist = []
        start_year = matchdict['Start Time'].datetime.year
        end_year = matchdict['End Time'].datetime.year
        tr = TimeRange(matchdict['Start Time'], matchdict['End Time'])
        for receiver in receivers:
            for year in range(start_year, end_year + 1):
                urlpattern = self.baseurl.format(Wavelength=receiver,
                                                 year=year,
                                                 ext=RECEIVER_EXT[receiver])
                scraper = Scraper(urlpattern, regex=True)
                filesmeta = scraper._extract_files_meta(tr,
                                                        extractor=self.pattern)
                for i in filesmeta:
                    rowdict = self.post_search_hook(i, matchdict)
                    metalist.append(rowdict)

        return QueryResponse(metalist, client=self)
Esempio n. 14
0
def test_missing_time_range():
    rows = [{'wibble': 1}]
    resp = QueryResponse(rows)

    assert resp.time_range() is None