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

Improve glider track map #166

Open
3 tasks
MOchiara opened this issue Dec 17, 2024 · 8 comments
Open
3 tasks

Improve glider track map #166

MOchiara opened this issue Dec 17, 2024 · 8 comments
Labels
enhancement New feature or request

Comments

@MOchiara
Copy link
Member

MOchiara commented Dec 17, 2024

Currently it is a bit hard to work with the glider track map (as any map really), especially when adding it to existing figures

  • Dynamic zoom in of the map
  • Sort out the colorbar when we use different figure size
  • Sort out fontsize when we use different figure size
@MOchiara MOchiara added the enhancement New feature or request label Dec 17, 2024
@callumrollo
Copy link
Member

A brief outline of a dynamic folium map

import folium
import geopandas as gpd

df = ds.to_pandas()[["LONGITUDE", "LATITUDE", "DIVE_NUM"]].groupby("DIVE_NUM").median()
gdf = gpd.GeoDataFrame(
    df, geometry=gpd.points_from_xy(df.LONGITUDE, df.LATITUDE), crs="EPSG:4326"
)

# OpenStreetMap
map = folium.Map(location=[df.LATITUDE.mean(), df.LONGITUDE.mean()], tiles="OpenStreetMap", zoom_start=8)
folium.GeoJson(
    data=gdf["geometry"],

).add_to(map)
map

@callumrollo
Copy link
Member

This will be a lot more flexible than the static cartopy map but it requires more heavy packages and obvs will not work with the pdf summary sheets. Not certain if it's something worth supporting. But I think interactive plots have a lot of advantages...

@MOchiara
Copy link
Member Author

MOchiara commented Feb 4, 2025

I really like it! And we could have it in the demo and keep somehow the old one for the pdf or can we get a static out of this one for the pdf?

@callumrollo
Copy link
Member

I think for notebooks these dynamic plots definitely make more sense (see also use of bokeh in IOOS QARTOD for interactive plots of qc flags https://github.com/ioos/ioos_qc/blob/main/docs/source/examples/QartodTestExample_Glider.ipynb)

We should have a real think of how to provide these interactive plots though. As they will only work in notebooks not reports and can be quite fragile. I would probably put all these interactive plots in a seperate module. Maybe a folder structure like

glidertest/plots/interactive.py
glidertest/plots/static.py

@callumrollo
Copy link
Member

I think this speaks to maybe the two divergent use cases of glidertest: exploratory analysis in a jupyter notebook, for which dynamic plots are a big improvement, and automated generation of reports, which have to be static

@MOchiara
Copy link
Member Author

MOchiara commented Feb 6, 2025

I think having both options int the separate codes is a good idea. You have a fair point with the purpose of glidertest and then how relevant or not the interactive plots are. This is something we can def discuss when you are here next week

@eleanorfrajka
Copy link
Collaborator

May be worth discussing whether this is beyond the scope of glidertest. I could see some arguments both ways.

Against fancy/heavy visualisation:
A1. Package management/robustness (kind of a big one for me.. biggest annoyance with python)
A2. Dilutes purpose of glidertest - I don't think glidertest is aimed at data exploration, but more a bulk evaluation of possible problems/ overview of a glider mission.
A3...

For fancy visualisation:
B1. Glidertest is about evaluating the quality of the glider data. Very difficult to do this effectively without good visualisation/figures.
B2. Interactive plots are great. Matlab plots were interactive by default and I do occasionally find it annoying that python plots are not.
B3...

Solutions--
If interactive plotting is in a separate module within glidertest like Callum suggested, is there a way to do a partial and full requirements? I.e., if you don't need the interactive stuff? Or does that get too complicated when coding to remember which package dependency is where?

Or alternatively, we could consider a fully-separate package of gliderviz which could be used alongside glidertest. Annoying thing there--you wouldn't be able to use it to replace the plotting within glidertest, unless you also require the user to install it, in which case you haven't circumvented the problem of package management (A1), but does keep glidertest closely aligned to the main purpose..

I haven't come across folium or geopandas yet, so therefore means they aren't in the most common set of packages needed?

@callumrollo
Copy link
Member

I think the question of scope is a good one. The primary focus of glidertest must remain bulk evaluation/automated detection of data issues.

There are good options for making it an optional requirement. One is to use Python's optional dependencies to add geopandas, folium etc. So a user would do pip install glidertest[interactive] to also install these dependencies. We would have a check in the interactive plot functions that raises an error with instructions if the user tries to call these functions without having installed the packages. You can see this in use if you install xarray without netcdf4 and try to read an .nc file.

Or, as you say, we can make the interactive plotting a fully separate package. Good things to discuss on Friday!

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