Exemplo n.º 1
0
 def search(self, *args, **kwargs):
     matchdict = self._get_match_dict(*args, **kwargs)
     timerange = TimeRange(matchdict['Start Time'], matchdict['End Time'])
     metalist = []
     for extdict, url in self._get_url_for_timerange(timerange):
         extdict['url'] = url
         rowdict = self.post_search_hook(extdict, matchdict)
         metalist.append(rowdict)
     return QueryResponse(metalist, client=self)
Exemplo n.º 2
0
 def search(self, *args, **kwargs):
     baseurl, pattern, matchdict = self.pre_search_hook(*args, **kwargs)
     timerange = matchdict['Time']
     metalist = []
     for url in self.get_observing_summary_filename(timerange):
         exdict = parse(pattern, url).named
         exdict['url'] = url
         rowdict = super().post_search_hook(exdict, matchdict)
         metalist.append(rowdict)
     return QueryResponse(metalist, client=self)
Exemplo n.º 3
0
 def search(self, *args, **kwargs):
     rowdict = self._get_match_dict(*args, **kwargs)
     for key in rowdict:
         if isinstance(rowdict[key], list):
             # uses first value among the list of possible values corresponding to an Attr
             # returned by `get_match_dict()` to be shown in query response table.
             rowdict[key] = rowdict[key][0]
     rowdict[
         'url'] = 'https://services.swpc.noaa.gov/json/solar-cycle/observed-solar-cycle-indices.json'
     rowdict['Instrument'] = 'NOAA-Indices'
     return QueryResponse([rowdict], client=self)
Exemplo n.º 4
0
 def search(self, *args, **kwargs):
     extractor1 = '{}/warehouse/{:4d}/SRS/{year:4d}{month:2d}{day:2d}SRS.txt'
     extractor2 = '{}/warehouse/{year:4d}/{}'
     matchdict = self._get_match_dict(*args, **kwargs)
     timerange = matchdict['Time']
     metalist = []
     for url in self._get_url_for_timerange(timerange):
         exdict1 = parse(extractor1, url)
         exdict2 = parse(extractor2, url)
         exdict = (exdict2 if exdict1 is None else exdict1).named
         exdict['url'] = url
         rowdict = self.post_search_hook(exdict, matchdict)
         metalist.append(rowdict)
     return QueryResponse(metalist, client=self)
Exemplo n.º 5
0
 def search(self, *args, **kwargs):
     matchdict = self._get_match_dict(*args, **kwargs)
     # this is for the case when the timerange overlaps with the provider change.
     if matchdict["Start Time"] < "2009-09-01" and matchdict[
             "End Time"] >= "2009-09-01":
         matchdict_before, matchdict_after = matchdict.copy(
         ), matchdict.copy()
         matchdict_after["Start Time"] = parse_time('2009-09-01')
         matchdict_before["End Time"] = parse_time('2009-08-31')
         metalist_before = self._get_metalist(matchdict_before)
         metalist_after = self._get_metalist(matchdict_after)
         metalist = metalist_before + metalist_after
     else:
         metalist = self._get_metalist(matchdict)
     return QueryResponse(metalist, client=self)
Exemplo n.º 6
0
 def search(self, *args, **kwargs):
     rowdict = self._get_match_dict(*args, **kwargs)
     for key in rowdict:
         if isinstance(rowdict[key], list):
             # uses first value among the list of possible values corresponding to an Attr
             # returned by `get_match_dict()` to be shown in query response table.
             rowdict[key] = rowdict[key][0]
     rowdict[
         'url'] = 'https://services.swpc.noaa.gov/json/solar-cycle/observed-solar-cycle-indices.json'
     rowdict['Instrument'] = 'NOAA-Indices'
     # These results are not dependant on time, but we allow time as a
     # parameter for easy searching, so remove time from the results table
     # injected by GenericClient.
     rowdict.pop('Start Time', None)
     rowdict.pop('End Time', None)
     return QueryResponse([rowdict], client=self)
Exemplo n.º 7
0
    def search(self, *args, **kwargs):
        supported_waves = [94, 131, 171, 195, 284, 304] * u.Angstrom
        all_waves = []
        matchdict = self._get_match_dict(*args, **kwargs)
        req_wave = matchdict.get('Wavelength', None)
        if req_wave is not None:
            wmin = req_wave.min.to(u.Angstrom, equivalencies=u.spectral())
            wmax = req_wave.max.to(u.Angstrom, equivalencies=u.spectral())
            req_wave = a.Wavelength(wmin, wmax)
            for wave in supported_waves:
                if wave in req_wave:
                    all_waves.append(int(wave.value))
        else:
            all_waves = [int(i.value) for i in supported_waves]
        all_satnos = matchdict.get('SatelliteNumber')
        all_levels = matchdict.get('Level')
        metalist = []

        # iterating over all possible Attr values through loops
        for satno in all_satnos:
            for level in all_levels:
                for wave in all_waves:
                    formdict = {'wave': wave, 'SatelliteNumber': satno}
                    if str(level) == '1b':
                        formdict['elem'] = 'fe'
                        if wave == 304:
                            formdict['elem'] = 'he'
                        baseurl = self.baseurl1b
                        pattern = self.pattern1b
                    elif str(level) == '2':
                        baseurl = self.baseurl2
                        pattern = self.pattern2
                    else:
                        raise ValueError(f"Level {level} is not supported.")
                    # formatting baseurl using Level, SatelliteNumber and Wavelength
                    urlpattern = baseurl.format(**formdict)

                    scraper = Scraper(urlpattern)
                    tr = TimeRange(matchdict['Start Time'],
                                   matchdict['End Time'])
                    filesmeta = scraper._extract_files_meta(tr,
                                                            extractor=pattern)
                    for i in filesmeta:
                        rowdict = self.post_search_hook(i, matchdict)
                        metalist.append(rowdict)

        return QueryResponse(metalist, client=self)