Sun#
- dace_query.sun.sun.Sun: SunClass = <dace_query.sun.sun.SunClass object>#
This is a singleton instance of the
SunClassclass.To use it, simply import it :
from dace_query.sun import Sun
- class dace_query.sun.sun.SunClass(dace_instance=None)#
Bases:
objectThe sun class. Use to retrieve data from the sun module.
Tip
A sun instance is already provided, to use it :
from dace_query.sun import Sun
- download(file_type, filters=None, compressed=True, output_directory=None, output_filename=None)#
Download Sun spectroscopy products (S1D, S2D, …).
Available spectroscopy product types
file_type
description
's1d'Extracted merged-1d spectra, corrected from the instrumental blaze, in the Sun’s rest-frame.
's2d'Extracted echelle-order 1d spectra, corrected from the instrumental blaze, in the Earth rest-frame.
'ccf'Cross Correlation Function (CCF) obtained by cross-correlating the S2D spectra with a synthetic mask optimised for the Sun.
'all'Complete product set.
See the Product description document on DACE for more details.
Specifying compression behavior
You can control the compression behavior of the downloaded files using the
compressedparameter.By default, files will be compressed into a
.tar.gzarchive if multiple files are downloaded.If you want to disable compression, set the
compressedparameter toFalse. (will result in a.tararchive).If you want to force compression, set the
compressedparameter toTrue. (will result in a.tar.gzarchive).When downloading large datasets, it is recommended to disable compression by setting
compressed=False. This will speed up the download process and reduce memory usage but will result in a larger file size.Output directory is the location where the downloaded files will be saved.
Output filename is the name of the downloaded file. If not specified, a default name will be used.
Note
When specifying
output_filename, be mindful of the appropriate file extension:When downloading a single file : match the extension to the file type (e.g.,
output_filename="lightcurve.fits") or leaveoutput_filenameasNoneto use the default name When downloading multiple files : use a.taror.tar.gzextension (e.g.,output_filename="my_data.tar.gz") or leaveoutput_filenameasNoneto use the default name- Parameters:
file_type (str) – The type of files to download
filters (Optional[dict]) – Filters to apply to the query
compressed (Optional[bool]) – Specify whether to compress the downloaded files. (
Truefor.tar.gz,Falsefor.tar)output_directory (Optional[str]) – The directory where files will be saved
output_filename (Optional[str]) – The filename for the download
- Return type:
None- Returns:
None
Downloading sun spectroscopy products using a filepath
from dace_query.sun import Sun filters_to_use = {'file_rootpath': {'contains': ['r.HARPN.2016-01-03T15-36-20.496.fits']}} Sun.download('s1d', filters=filters_to_use, output_directory='/tmp', output_filename='sun_spectroscopy_data.tar.gz')
Downloading sun spectroscopy products using a specific date
from dace_query.sun import Sun filters_to_use = {'date_night': {'contains': ['2016-12-10']}} Sun.download('s1d', filters=filters_to_use)
- download_files(file_type='s1d', files=None, output_directory=None, output_filename=None)#
Deprecated since version 2.0.0: This method is deprecated and will be removed in a future version. Use
download()with`filters`instead :files = ['harpn/DRS-3.0.1/reduced/2018-07-16/r.HARPN.2018-07-17T08-10-32.225.fits'] filters: dict = { 'file_rootpath': {'contains': files} } Sun.download(file_type='s1d', filters=filters)
Download reduction products specified in argument for the list of raw files specified and save it locally.
Available spectroscopy product types
file_type
description
's1d'Extracted merged-1d spectra, corrected from the instrumental blaze, in the Sun’s rest-frame.
's2d'Extracted echelle-order 1d spectra, corrected from the instrumental blaze, in the Earth rest-frame.
'ccf'Cross Correlation Function (CCF) obtained by cross-correlating the S2D spectra with a synthetic mask optimised for the Sun.
'all'Complete product set.
See the Product description document on DACE for more details.
- Parameters:
file_type (Optional[str]) – The type of files to download
files (list[str]) – The raw files
output_directory (Optional[str]) – The directory where files will be saved
output_filename (Optional[str]) – The filename for the download
- Return type:
None- Returns:
None
Downloading sun spectroscopy products given a list of files
from dace_query.sun import Sun files_to_retrieve = ['harpn/DRS-2.3.5/reduced/2016-01-03/r.HARPN.2016-01-03T15-36-20.496.fits'] Sun.download_files('s1d', files=files_to_retrieve, output_directory='/tmp', output_filename='files.tar.gz')
- download_public_release_all(year, month, output_directory=None, output_filename=None)#
Download public sun data of year and month specified in arguments.
- Parameters:
year (str) – The year for sun data
month (str) – The month for sun data
output_directory (Optional[str]) – The directory where files will be saved
output_filename (Optional[str]) – The filename for the download
- Return type:
None- Returns:
None
Downloading public sun data for a given year and month
from dace_query.sun import Sun Sun.download_public_release_all('2015', '12') # Downloads the sun data for December 2015
- download_public_release_ccf(year, output_directory=None, output_filename=None)#
Download public ccf data realease of year specified in argument.
- Parameters:
year (str) – The year for the ccf data
output_directory (Optional[str]) – The directory where files will be saved
output_filename (Optional[str]) – The filename for the download
- Return type:
None- Returns:
None
Downloading public ccf data for a given year
from dace_query.sun import Sun Sun.download_public_release_ccf('2015') # Downloads the CCF data for 2015
- download_public_release_timeseries(period='2015-2018', output_directory=None, output_filename=None)#
Download public timeseries data release for a specified period and save it locally.
The only available period is
'2015-2018'.- Parameters:
period (Optional[str]) – The period
output_directory (Optional[str]) – The directory where files will be saved
output_filename (Optional[str]) – The filename for the download
- Return type:
None- Returns:
None
Downloading public timeseries data
from dace_query.sun import Sun Sun.download_public_release_timeseries() # Downloads the timeseries data from 2015 to 2018
- query_database(limit=200000, filters=None, sort=None, output_format=None)#
Query the sun database to retrieve data in the chosen format.
Filters and sorting order can be applied to the query via named arguments (see Filtering and sorting).
All available formats are defined in this section (see Output formats).
- Parameters:
limit (Optional[int]) – Maximum number of rows to return
filters (Optional[dict]) – Filters to apply to the query
sort (Optional[dict]) – Sort order to apply to the query
output_format (Optional[str]) – Type of data returns
- Returns:
The desired data in the chosen output format
- Return type:
dict[str, ndarray] or DataFrame or Table or dict
Getting all sun data
from dace_query.sun import Sun values = Sun.query_database()