cal-adapt / climakitae

A Python toolkit for retrieving, visualizing, and performing scientific analyses with data from the Cal-Adapt Analytics Engine.
https://climakitae.readthedocs.io
BSD 3-Clause "New" or "Revised" License
21 stars 2 forks source link

Export Dataset to CSV #270

Closed Tianchi-Liu closed 1 year ago

Tianchi-Liu commented 1 year ago

This PR allows users to export xarray Dataset to the CSV format. Previously only DataArray can be exported to CSV. Now, users are able to export station data as well as all the Dataset outputs from the threshold_tools_basics and threshold_tools_application_examples notebooks.

Implementation details:

As an example, for a Dataset containing 3 stations, the header of the exported CSV looks like this: Screenshot 2023-08-15 133239

Note: The climate variable name is not currently in the header as it is not readily available in the Dataset. Will be pulled from variable_description.csv later.

To test: In the refactor branch of cae-notebooks, try export some station data and/or other Dataset.

elehmer commented 1 year ago

Thanks @Tianchi-Liu! I have merged this into the refactor branch. I renamed export_dataset to export and exposed it as a top level method. The Export class has been removed along with the dialog