Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plot labels - to determine variable names + units from the dataset #110

Open
1 of 3 tasks
eleanorfrajka opened this issue Nov 14, 2024 · 2 comments
Open
1 of 3 tasks
Assignees
Labels
enhancement New feature or request

Comments

@eleanorfrajka
Copy link
Collaborator

eleanorfrajka commented Nov 14, 2024

Plots can take advantage of variable attributes for setting labels and units: Labels from long_name, and units from units. Might need some little utility to convert units to something pretty. E.g. 'm s-1' could be translated to 'm s$^{-1}$'. Although, I'm really not sure who decided "PSAL" would have units 1e-3. Ok, I read a little further through the vocabularies.py, and scratch that. long_name is not great "Temperature of the water body by CTD". Neither is standard_name "sea_water_pressure". Maybe somewhere we can set up a dictionary based on variable name and "plotting_name" or something.

BP700: My paper uses b${bp}$(700) for red backscatter (probably based on something by Sackmann or Mary-Jane Perry). Could be "Red backscatter, b${bp}$(700)"
PSAL: "Practical salinity"
TEMP: "Temperature"
SA: "Absolute salinity"
DENSITY: "In situ density"
DOXY: "Dissolved oxygen"
When the dictionary doesn't have a key for the variable the user wants to plot, then it can use just the varname.

Then the label_str = label_dict['BP700'] + utilities.nice_units(ds['BP700'].attrs['units'])
and the function (or widget) .nice_units() can translate from 'degrees_Celcius' to '$^\circ$C' and from 'm-1' to 'm$^{-1}$', etc.

@callumrollo callumrollo self-assigned this Nov 14, 2024
@callumrollo
Copy link
Member

I think this is a good idea. Having looked into it, this will require some changes to the functions that we have. We should pass xarray datasets and dataarrays with their corresponding metadata to/from functions like plot_updown_bias so that we can use the unit metadata and long/standard names to construct nice labels. This will also make the toolbox generally more interoperable and easier for the end user (no need to pass both the chlorophyll variable and the lable "chlorophyll a [mmol / litre]" to the plotting function

@eleanorfrajka eleanorfrajka changed the title Plot labels Plot labels - to determine variable names + units from the dataset Nov 28, 2024
@eleanorfrajka eleanorfrajka added the enhancement New feature or request label Nov 28, 2024
@MOchiara
Copy link
Member

MOchiara commented Dec 4, 2024

I am working on it but I am having a little doubt: in some case standard_name is better to use and in some other long_name is better.
Examples:
image

Eleanor already noticed this and we can have a plotting dictionary in utilities or something like that. What do you think? I can maybe prepare a draft

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

No branches or pull requests

3 participants