def search_metadata(self, *query, **kwargs): """ Get the metadata of all the files obtained in a search query. Builds a jsoc query, similar to query method, and takes similar inputs. Complex queries to be easily formed using logical operators such as ``&`` and ``|``, in the same way as the query function. Parameters ---------- query : a variable number of `~sunpy.net.jsoc.attrs` as parameters, which are chained together using the ``AND`` (``&``) operator. Returns ------- res : `~pandas.DataFrame` object A collection of metadata of all the files. """ query = and_(*query) blocks = [] res = pd.DataFrame() for block in walker.create(query): iargs = kwargs.copy() iargs.update(block) iargs.update({'meta': True}) blocks.append(iargs) res = res.append(self._lookup_records(iargs)) return res
def search_metadata(self, *query, **kwargs): """ Get the metadata of all the files obtained in a search query. Builds a jsoc query, similar to query method, and takes similar inputs. Complex queries to be easily formed using logical operators such as ``&`` and ``|``, in the same way as the query function. Parameters ---------- query : a variable number of `~sunpy.net.jsoc.attrs` as parameters, which are chained together using the ``AND`` (``&``) operator. Returns ------- res : `~pandas.DataFrame` object A collection of metadata of all the files. Example ------- Request metadata or all all AIA 304 image data between 2014-01-01T00:00 and 2014-01-01T01:00. Since, the function only performs a lookdata, and does not make a proper export request, attributes like Segment need not be passed:: >>> import astropy.units as u >>> from sunpy.net import jsoc >>> from sunpy.net import attrs as a >>> client = jsoc.JSOCClient() # doctest: +REMOTE_DATA >>> metadata = client.search_metadata( ... a.Time('2014-01-01T00:00:00', '2014-01-01T00:01:00'), ... a.jsoc.Series('aia.lev1_euv_12s'), a.jsoc.Wavelength(304*u.AA)) # doctest: +REMOTE_DATA >>> print(metadata[['T_OBS', 'WAVELNTH']]) # doctest: +REMOTE_DATA T_OBS WAVELNTH aia.lev1_euv_12s[2014-01-01T00:00:01Z][304] 2014-01-01T00:00:08.57Z 304 aia.lev1_euv_12s[2014-01-01T00:00:13Z][304] 2014-01-01T00:00:20.58Z 304 aia.lev1_euv_12s[2014-01-01T00:00:25Z][304] 2014-01-01T00:00:32.57Z 304 aia.lev1_euv_12s[2014-01-01T00:00:37Z][304] 2014-01-01T00:00:44.58Z 304 aia.lev1_euv_12s[2014-01-01T00:00:49Z][304] 2014-01-01T00:00:56.57Z 304 aia.lev1_euv_12s[2014-01-01T00:01:01Z][304] 2014-01-01T00:01:08.59Z 304 """ query = and_(*query) blocks = [] res = pd.DataFrame() for block in walker.create(query): iargs = kwargs.copy() iargs.update(block) iargs.update({'meta': True}) blocks.append(iargs) res = res.append(self._lookup_records(iargs)) return res
def query(self, *query, **kwargs): """ Build a JSOC query and submit it to JSOC for processing. Takes a variable number of :mod:`sunpy.net.jsoc.attrs` as parameters, which are chained together using the AND (`&`) operator. Complex queries to be easily formed using logical operators such as `&` and `|`, in the same way as the VSO client. Examples -------- Request all AIA 304 image data between 2010-01-01T00:00 and 2010-01-01T01:00 in rice compressed form. >>> import astropy.units as u >>> from sunpy.net import jsoc >>> from sunpy.net import attrs as a >>> client = jsoc.JSOCClient() >>> response = client.query(a.Time('2010-01-01T00:00:00', '2010-01-01T01:00:00'), ... a.jsoc.Series('aia.lev1_euv_12s'), a.jsoc.Wavelength(304*u.AA), ... a.jsoc.Compression('rice'), a.jsoc.Segment('image')) Returns ------- results : JSOCResults object A collection of records that the query returns. """ return_results = JSOCResponse() query = and_(*query) blocks = [] for block in walker.create(query): iargs = kwargs.copy() iargs.update(block) blocks.append(iargs) return_results.append(self._lookup_records(iargs)) return_results.query_args = blocks return return_results
def search(self, *query, **kwargs): """ Build a JSOC query and submit it to JSOC for processing. Takes a variable number of :mod:`sunpy.net.jsoc.attrs` as parameters, which are chained together using the AND (`&`) operator. Complex queries to be easily formed using logical operators such as `&` and `|`, in the same way as the VSO client. Examples -------- Request all AIA 304 image data between 2010-01-01T00:00 and 2010-01-01T01:00 in rice compressed form. >>> import astropy.units as u >>> from sunpy.net import jsoc >>> from sunpy.net import attrs as a >>> client = jsoc.JSOCClient() >>> response = client.search(a.Time('2010-01-01T00:00:00', '2010-01-01T01:00:00'), ... a.jsoc.Series('aia.lev1_euv_12s'), a.jsoc.Wavelength(304*u.AA), ... a.jsoc.Compression('rice'), a.jsoc.Segment('image')) Returns ------- results : JSOCResults object A collection of records that the query returns. """ return_results = JSOCResponse() query = and_(*query) blocks = [] for block in walker.create(query): iargs = kwargs.copy() iargs.update(block) blocks.append(iargs) return_results.append(self._lookup_records(iargs)) return_results.query_args = blocks return return_results
def search(self, *query, **kwargs): """ Build a JSOC query and submit it to JSOC for processing. Takes a variable number of `~sunpy.net.jsoc.attrs` as parameters, which are chained together using the AND (`&`) operator. Complex queries to be easily formed using logical operators such as `&` and `|`, in the same way as the VSO client. Parameters ---------- query : a variable number of `~sunpy.net.jsoc.attrs` as parameters, which are chained together using the ``AND`` (``&``) operator. Returns ------- response : `~sunpy.net.jsoc.jsoc.JSOCResponse` object A collection of records that the query returns. Examples -------- *Example 1* Request all AIA 304 image data between 2014-01-01T00:00 and 2014-01-01T01:00:: >>> import astropy.units as u >>> from sunpy.net import jsoc >>> from sunpy.net import attrs as a >>> client = jsoc.JSOCClient() # doctest: +REMOTE_DATA >>> response = client.search(a.Time('2017-09-06T12:00:00', '2017-09-06T12:02:00'), ... a.jsoc.Series('aia.lev1_euv_12s'), a.jsoc.Wavelength(304*u.AA), ... a.jsoc.Segment('image')) # doctest: +REMOTE_DATA >>> print(response) # doctest: +REMOTE_DATA T_REC TELESCOP INSTRUME WAVELNTH CAR_ROT -------------------- -------- -------- -------- ------- 2017-09-06T11:59:59Z SDO/AIA AIA_4 304 2194 2017-09-06T12:00:11Z SDO/AIA AIA_4 304 2194 2017-09-06T12:00:23Z SDO/AIA AIA_4 304 2194 2017-09-06T12:00:35Z SDO/AIA AIA_4 304 2194 2017-09-06T12:00:47Z SDO/AIA AIA_4 304 2194 2017-09-06T12:00:59Z SDO/AIA AIA_4 304 2194 2017-09-06T12:01:11Z SDO/AIA AIA_4 304 2194 2017-09-06T12:01:23Z SDO/AIA AIA_4 304 2194 2017-09-06T12:01:35Z SDO/AIA AIA_4 304 2194 2017-09-06T12:01:47Z SDO/AIA AIA_4 304 2194 2017-09-06T12:01:59Z SDO/AIA AIA_4 304 2194 *Example 2* Request keyword data of ``hmi.v_45s`` for certain specific keywords only:: >>> import astropy.units as u >>> from sunpy.net import jsoc >>> from sunpy.net import attrs as a >>> client = jsoc.JSOCClient() # doctest: +REMOTE_DATA >>> response = client.search(a.Time('2014-01-01T00:00:00', '2014-01-01T00:10:00'), ... a.jsoc.Series('hmi.v_45s'), ... a.jsoc.Keys('T_REC, DATAMEAN, OBS_VR')) # doctest: +REMOTE_DATA >>> print(response) # doctest: +REMOTE_DATA T_REC DATAMEAN OBS_VR ----------------------- ------------------ ------------------ 2014.01.01_00:00:45_TAI 1906.518188 1911.202614 2014.01.01_00:01:30_TAI 1908.876221 1913.945512 2014.01.01_00:02:15_TAI 1911.7771 1916.6679989999998 2014.01.01_00:03:00_TAI 1913.422485 1919.3699239999999 2014.01.01_00:03:45_TAI 1916.500488 1922.050862 2014.01.01_00:04:30_TAI 1920.414795 1924.7110050000001 2014.01.01_00:05:15_TAI 1922.636963 1927.35015 2014.01.01_00:06:00_TAI 1924.6973879999998 1929.968523 2014.01.01_00:06:45_TAI 1927.758301 1932.5664510000001 2014.01.01_00:07:30_TAI 1929.646118 1935.14288 2014.01.01_00:08:15_TAI 1932.097046 1937.698521 2014.01.01_00:09:00_TAI 1935.7286379999998 1940.23353 2014.01.01_00:09:45_TAI 1937.754028 1942.747605 2014.01.01_00:10:30_TAI 1940.1462399999998 1945.241147 *Example 3* Request data of ``aia.lev1_euv_12s`` on the basis of PrimeKeys other than ``T_REC``:: >>> import astropy.units as u >>> from sunpy.net import jsoc >>> from sunpy.net import attrs as a >>> client = jsoc.JSOCClient() # doctest: +REMOTE_DATA >>> response = client.search(a.Time('2014-01-01T00:00:00', '2014-01-01T00:01:00'), ... a.jsoc.Series('aia.lev1_euv_12s'), ... a.jsoc.PrimeKey('WAVELNTH','171')) # doctest: +REMOTE_DATA >>> print(response) # doctest: +REMOTE_DATA T_REC TELESCOP INSTRUME WAVELNTH CAR_ROT -------------------- -------- -------- -------- ------- 2014-01-01T00:00:01Z SDO/AIA AIA_3 171 2145 2014-01-01T00:00:13Z SDO/AIA AIA_3 171 2145 2014-01-01T00:00:25Z SDO/AIA AIA_3 171 2145 2014-01-01T00:00:37Z SDO/AIA AIA_3 171 2145 2014-01-01T00:00:49Z SDO/AIA AIA_3 171 2145 2014-01-01T00:01:01Z SDO/AIA AIA_3 171 2145 """ return_results = JSOCResponse() query = and_(*query) blocks = [] for block in walker.create(query): iargs = kwargs.copy() iargs.update(block) blocks.append(iargs) return_results.append(self._lookup_records(iargs)) return_results.query_args = blocks return return_results
def search(self, *query, **kwargs): """ Build a JSOC query and submit it to JSOC for processing. Takes a variable number of `~sunpy.net.jsoc.attrs` as parameters, which are chained together using the AND (``&``) operator. Complex queries to be easily formed using logical operators such as ``&`` and ``|``, in the same way as the VSO client. Parameters ---------- *query : a variable number of `~sunpy.net.jsoc.attrs` as parameters, which are chained together using the ``AND`` (``&``) operator. Returns ------- response : `~sunpy.net.jsoc.jsoc.JSOCResponse` object A collection of records that the query returns. Examples -------- *Example 1* Request all AIA 304 image data between 2014-01-01T00:00 and 2014-01-01T01:00:: >>> import astropy.units as u >>> from sunpy.net import jsoc >>> from sunpy.net import attrs as a >>> client = jsoc.JSOCClient() # doctest: +REMOTE_DATA >>> response = client.search(a.Time('2017-09-06T12:00:00', '2017-09-06T12:02:00'), ... a.jsoc.Series('aia.lev1_euv_12s'), a.Wavelength(304*u.AA), ... a.jsoc.Segment('image')) # doctest: +REMOTE_DATA >>> print(response) # doctest: +REMOTE_DATA T_REC TELESCOP INSTRUME WAVELNTH CAR_ROT -------------------- -------- -------- -------- ------- 2017-09-06T11:59:59Z SDO/AIA AIA_4 304 2194 2017-09-06T12:00:11Z SDO/AIA AIA_4 304 2194 2017-09-06T12:00:23Z SDO/AIA AIA_4 304 2194 2017-09-06T12:00:35Z SDO/AIA AIA_4 304 2194 2017-09-06T12:00:47Z SDO/AIA AIA_4 304 2194 2017-09-06T12:00:59Z SDO/AIA AIA_4 304 2194 2017-09-06T12:01:11Z SDO/AIA AIA_4 304 2194 2017-09-06T12:01:23Z SDO/AIA AIA_4 304 2194 2017-09-06T12:01:35Z SDO/AIA AIA_4 304 2194 2017-09-06T12:01:47Z SDO/AIA AIA_4 304 2194 2017-09-06T12:01:59Z SDO/AIA AIA_4 304 2194 *Example 2* Request keyword data of ``hmi.v_45s`` and show specific columns only:: >>> import astropy.units as u >>> from sunpy.net import jsoc >>> from sunpy.net import attrs as a >>> client = jsoc.JSOCClient() # doctest: +REMOTE_DATA >>> response = client.search(a.Time('2014-01-01T00:00:00', '2014-01-01T00:10:00'), ... a.jsoc.Series('hmi.v_45s')) # doctest: +REMOTE_DATA >>> print(response.show('T_REC', 'WAVELNTH', 'CAR_ROT')) # doctest: +REMOTE_DATA T_REC WAVELNTH CAR_ROT ----------------------- -------- ------- 2014.01.01_00:00:45_TAI 6173.0 2145 2014.01.01_00:01:30_TAI 6173.0 2145 2014.01.01_00:02:15_TAI 6173.0 2145 2014.01.01_00:03:00_TAI 6173.0 2145 2014.01.01_00:03:45_TAI 6173.0 2145 2014.01.01_00:04:30_TAI 6173.0 2145 2014.01.01_00:05:15_TAI 6173.0 2145 2014.01.01_00:06:00_TAI 6173.0 2145 2014.01.01_00:06:45_TAI 6173.0 2145 2014.01.01_00:07:30_TAI 6173.0 2145 2014.01.01_00:08:15_TAI 6173.0 2145 2014.01.01_00:09:00_TAI 6173.0 2145 2014.01.01_00:09:45_TAI 6173.0 2145 2014.01.01_00:10:30_TAI 6173.0 2145 *Example 3* Request data of ``aia.lev1_euv_12s`` on the basis of PrimeKeys other than ``T_REC``:: >>> import astropy.units as u >>> from sunpy.net import jsoc >>> from sunpy.net import attrs as a >>> client = jsoc.JSOCClient() # doctest: +REMOTE_DATA >>> response = client.search(a.Time('2014-01-01T00:00:00', '2014-01-01T00:01:00'), ... a.jsoc.Series('aia.lev1_euv_12s'), ... a.jsoc.PrimeKey('WAVELNTH','171')) # doctest: +REMOTE_DATA >>> print(response) # doctest: +REMOTE_DATA T_REC TELESCOP INSTRUME WAVELNTH CAR_ROT -------------------- -------- -------- -------- ------- 2014-01-01T00:00:01Z SDO/AIA AIA_3 171 2145 2014-01-01T00:00:13Z SDO/AIA AIA_3 171 2145 2014-01-01T00:00:25Z SDO/AIA AIA_3 171 2145 2014-01-01T00:00:37Z SDO/AIA AIA_3 171 2145 2014-01-01T00:00:49Z SDO/AIA AIA_3 171 2145 2014-01-01T00:01:01Z SDO/AIA AIA_3 171 2145 """ return_results = JSOCResponse(client=self) query = and_(*query) blocks = [] for block in walker.create(query): iargs = kwargs.copy() iargs.update(block) # Update blocks with deep copy of iargs because in _make_recordset we use .pop() on element from iargs blocks.append(copy.deepcopy(iargs)) return_results = astropy.table.vstack( [return_results, self._lookup_records(iargs)]) return_results.query_args = blocks return_results._original_num_rows = len(return_results) return return_results
def jsoc_query(self, *query, **kwargs): """ Build a JSOC query and submit it to JSOC for processing. Parameters ---------- start_time: datetime, astropy.time or string The time in UTC (or astropy.time object) specifying the start time. end_time: datetime, astropy.time or string The time in UTC (or astropy.time object) specifying the end time. series: string A string representing the JSOC data series to download e.g. 'hmi.M_45s' notify: string An email address to get a notification to when JSOC has staged your request protocol: string The type of download to request one of ("FITS", "JPEG", "MPG", "MP4", or "as-is"). Only FITS is supported, the others will require extra keywords. compression: string 'rice' or None, download FITS files with RICE compression. kwargs: dict Extra keywords to put into the POST payload to JSOC. Returns ------- requestIDs: list A list of the requestIDs generated from your query """ # A little (hidden) debug feature return_resp = kwargs.pop('return_resp', False) return_response = [] return_reqid = [] query = and_(*query) for block in walker.create(query): iargs = kwargs.copy() iargs.update(block) # Do a multi-request for each query block responses = self._multi_request(**iargs) for i, response in enumerate(responses): #TODD: catch non 200 return if response.json()['status'] != 2: warnings.warn( Warning("Query {0} retuned status {1} with error {2}".format(i, response.json()['status'], response.json()['error']))) responses.pop(i) #Extract the IDs from the JSON requestIDs = [response.json()['requestid'] for response in responses] return_reqid.extend(requestIDs) return_response.extend(responses) if return_resp: return return_response return return_reqid