G
YouTube TikTok Games
Skip to content

Add metadata support for xarray dataset returns from read_data - #32

Open
LASP-Luke wants to merge 1 commit into
mainfrom
LATIS-1340-add-metadata-to-python-client-xarray
Open

LASP-Luke wants to merge 1 commit into
mainfrom
LATIS-1340-add-metadata-to-python-client-xarray

Conversation

@LASP-Luke

@LASP-Luke LASP-Luke commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

This PR introduces metadata fetching for xarray dataset global and variable metadata schemas which are applied to xarray datasets before returning them from the read_data function.

This metadata functionality has not yet been implemented for join requests.

Some minor imports cleanup and docstring additions were also made in this PR.

@LASP-Luke LASP-Luke added the enhancement New feature or request label Nov 11, 2026
@LASP-Luke

LASP-Luke commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor Author

Here's an example of the metadata attributes added during a request for a TSIS (xarray) dataset:

Global attributes:

id: tsis_tsi_6hr
temporal_coverage: 2018-01-11/

Variable attributes:

time:
id: time
type: double
units: JD
title: Nominal Time

tsi_1au:
id: tsi_1au
type: double
units: W/m^2
missing_value: 0
title: Total Solar Irradiance (TSI) at 1-AU

instrument_accuracy_1au:
id: instrument_accuracy_1au
type: double
units: W/m^2
missing_value: 0
title: Instrument Accuracy in 1-AU TSI, 1 sigma

instrument_precision_1au:
id: instrument_precision_1au
type: double
units: W/m^2
missing_value: 0
title: Instrument Precision in TSI at 1-AU, 1 sigma

solar_standard_deviation_1au:
id: solar_standard_deviation_1au
type: double
units: W/m^2
missing_value: 0
title: Solar Standard Deviation in 1-AU TSI, 1 sigma

measurement_uncertainty_1au:
id: measurement_uncertainty_1au
type: double
units: W/m^2
missing_value: 0
title: Total Uncertainty in TSI at 1-AU, 1 sigma

tsi_true_earth:
id: tsi_true_earth
type: double
units: W/m^2
missing_value: 0
title: Total Solar Irradiance at Earth distance

instrument_accuracy_true_earth:
id: instrument_accuracy_true_earth
type: double
units: W/m^2
missing_value: 0
title: Instrument Accuracy at Earth distance, 1 sigma

instrument_precision_true_earth:
id: instrument_precision_true_earth
type: double
units: W/m^2
missing_value: 0
title: Instrument Precision at Earth distance, 1 sigma

solar_standard_deviation_true_earth:
id: solar_standard_deviation_true_earth
type: double
units: W/m^2
missing_value: 0
title: Solar Standard Deviation in TSI at Earth, 1 sigma

measurement_uncertainty_true_earth:
id: measurement_uncertainty_true_earth
type: double
units: W/m^2
missing_value: 0
title: Total Uncertainty in TSI at Earth distance, 1 sigma

avg_measurement_date:
id: avg_measurement_date
type: double
units: JD
missing_value: 0
title: Average Data Time

std_dev_measurement_date:
id: std_dev_measurement_date
type: double
units: days
missing_value: 0
title: Stdev of Average Data Time, 1 sigma

provisional_flag:
id: provisional_flag
type: int
title: Provisional Flag, 1=provisional data, 0=final data

index:

@dlindhol dlindhol left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fought with PyCharm a while and had to tweak some imports. (Any advice would be appreciated.) Otherwise, it looks good to me!

Could you also update the README with the xarray option? Mention that it will include metadata.

Comment thread src/latis/client.py
base (str): The base URL of the LaTiS instance
dataset (str): A dataset identifier string
query (str): The query parameters string used to filter dataset results
auth (HTTPBasicAuth): An authentication object used to authenticate with the LaTiS server

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might add "optional". Also, API keys are supported in addition to basic auth.

Comment thread src/latis/metadata.py
model_config = pydantic.ConfigDict(extra="ignore")
# Required metadata items
id: str
# Optional metadata items

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we discuss including optional title and description in the dataset metadata? Those would be handy.

Sorry for any scope creep.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants