Exemple #1
0
    def post_search_hook(self, i, matchdict):
        tr = get_timerange_from_exdict(i)
        rowdict = OrderedDict()
        rowdict["Time"] = TimeRange(tr.start, tr.end)
        rowdict["Start Time"] = tr.start.strftime(TIME_FORMAT)
        rowdict["End Time"] = tr.end.strftime(TIME_FORMAT)
        rowdict["Instrument"] = matchdict["Instrument"][0].upper()
        rowdict["SatelliteNumber"] = i["SatelliteNumber"]
        rowdict["Physobs"] = matchdict["Physobs"][0]
        rowdict["url"] = i["url"]
        rowdict["Source"] = matchdict["Source"][0]
        if i["url"].endswith(".fits"):
            rowdict["Provider"] = matchdict["Provider"][0]
        else:
            rowdict["Provider"] = matchdict["Provider"][1]

        return rowdict
Exemple #2
0
    def post_search_hook(self, i, matchdict):
        tr = get_timerange_from_exdict(i)
        rowdict = OrderedDict()
        rowdict['Start Time'] = tr.start
        rowdict['Start Time'].format = 'iso'
        rowdict['End Time'] = tr.end
        rowdict['End Time'].format = 'iso'
        rowdict["Instrument"] = matchdict["Instrument"][0].upper()
        rowdict["SatelliteNumber"] = i["SatelliteNumber"]
        rowdict["Physobs"] = matchdict["Physobs"][0]
        rowdict["url"] = i["url"]
        rowdict["Source"] = matchdict["Source"][0]
        if i["url"].endswith(".fits"):
            rowdict["Provider"] = matchdict["Provider"][0]
        else:
            rowdict["Provider"] = matchdict["Provider"][1]

        return rowdict
Exemple #3
0
    def post_search_hook(self, exdict, matchdict):
        """
        Helper function used after :func:`~sunpy.net.dataretriever.GenericClient.search`
        which makes the extracted metadata representable in a query response table.

        Parameters
        ----------
        exdict: `dict`
            Represents metadata extracted from files.
        matchdict: `dict`
            Contains attr values accessed from `register_values()`
            and the search query itself.

        Returns
        -------
        rowdict: `~collections.OrderedDict`
            An Ordered Dictionary which is used by `QueryResponse`
            to show results.
        """
        rowdict = OrderedDict()
        tr = get_timerange_from_exdict(exdict)
        start = tr.start
        start.format = 'iso'
        end = tr.end
        end.format = 'iso'
        rowdict['Start Time'] = start
        rowdict['End Time'] = end
        for k in matchdict:
            if k not in ('Start Time', 'End Time', 'Wavelength'):
                if k == 'Physobs':
                    # not changing case for Phsyobs
                    rowdict[k] = matchdict[k][0]
                else:
                    rowdict[k] = matchdict[k][0].upper()
        for k in exdict:
            if k not in ['year', 'month', 'day', 'hour', 'minute', 'second']:
                rowdict[k] = exdict[k]
        return rowdict
Exemple #4
0
def test_get_timerange_with_extractor(exdict, start, end):
    tr = TimeRange(start, end)
    file_timerange = get_timerange_from_exdict(exdict)
    assert file_timerange == tr