|
| 1 | +--- |
| 2 | +jupytext: |
| 3 | + formats: md:myst |
| 4 | + text_representation: |
| 5 | + extension: .md |
| 6 | + format_name: myst |
| 7 | + format_version: 0.13 |
| 8 | + jupytext_version: 1.17.2 |
| 9 | +kernelspec: |
| 10 | + display_name: Python 3 (ipykernel) |
| 11 | + language: python |
| 12 | + name: python3 |
| 13 | +--- |
| 14 | + |
| 15 | +(dkist:examples:dataset-retrieval-and-metadata)= |
| 16 | +# Retrieving a Dataset and Inspecting Metadata |
| 17 | + |
| 18 | +In this example we will search for a DKIST dataset by dataset ID, download its metadata ASDF file, and inspect some of the metadata stored in it. |
| 19 | + |
| 20 | +```{code-cell} ipython3 |
| 21 | +from sunpy.net import Fido, attrs as a |
| 22 | +
|
| 23 | +import dkist |
| 24 | +import dkist.net |
| 25 | +``` |
| 26 | + |
| 27 | +Here we use the VISP dataset [ALQRZ](https://dkist.data.nso.edu/datasetview/ALQRZ). |
| 28 | +To inspect a different dataset, edit only `DATASET_ID`. |
| 29 | + |
| 30 | +```{code-cell} ipython3 |
| 31 | +DATASET_ID = "ALQRZ" |
| 32 | +``` |
| 33 | + |
| 34 | +First we search for the dataset. |
| 35 | +The `Status("any")` attribute means the search will return this dataset ID irrespective of its processing status. |
| 36 | + |
| 37 | +```{code-cell} ipython3 |
| 38 | +search_results = Fido.search(a.dkist.Dataset(DATASET_ID), a.dkist.Status("any")) |
| 39 | +search_results |
| 40 | +``` |
| 41 | + |
| 42 | +The search result points to the metadata ASDF file. |
| 43 | +We can fetch that file directly with `Fido.fetch`. |
| 44 | + |
| 45 | +```{code-cell} ipython3 |
| 46 | +asdf_file = Fido.fetch(search_results) |
| 47 | +asdf_file |
| 48 | +``` |
| 49 | + |
| 50 | +Now we can load the ASDF file as a `dkist.Dataset`. |
| 51 | +This describes the dataset and its file references without downloading all of the FITS files. |
| 52 | + |
| 53 | +```{code-cell} ipython3 |
| 54 | +dataset = dkist.load_dataset(asdf_file) |
| 55 | +dataset |
| 56 | +``` |
| 57 | + |
| 58 | +The dataset inventory contains searchable metadata from the DKIST Data Center. |
| 59 | +Here we display the entries related to data quality. |
| 60 | + |
| 61 | +```{code-cell} ipython3 |
| 62 | +{ |
| 63 | + key: value |
| 64 | + for key, value in dataset.meta["inventory"].items() |
| 65 | + if key.lower().startswith("quality") |
| 66 | +} |
| 67 | +``` |
| 68 | + |
| 69 | +Each calibrated dataset also has a quality report. |
| 70 | +This method downloads the report PDF and returns a `parfive.Results` object with the local filename. |
| 71 | + |
| 72 | +```{code-cell} ipython3 |
| 73 | +quality_report = dataset.files.quality_report() |
| 74 | +quality_report |
| 75 | +``` |
| 76 | + |
| 77 | +The ASDF file can also contain more detailed metadata about how the dataset was generated. |
| 78 | +The following fields describe the input parameters, the observe and calibration frames, and the recipe configuration. |
| 79 | + |
| 80 | +```{code-cell} ipython3 |
| 81 | +dataset.meta["parameters"] |
| 82 | +``` |
| 83 | + |
| 84 | +```{code-cell} ipython3 |
| 85 | +dataset.meta["observation_input_frames"] |
| 86 | +``` |
| 87 | + |
| 88 | +```{code-cell} ipython3 |
| 89 | +dataset.meta["calibration_input_frames"] |
| 90 | +``` |
| 91 | + |
| 92 | +```{code-cell} ipython3 |
| 93 | +dataset.meta["recipe_run_config"] |
| 94 | +``` |
0 commit comments