FormingWorlds / PROTEUS

Coupled atmosphere-interior framework to simulate the temporal evolution of rocky planets.
https://fwl-proteus.readthedocs.io
Apache License 2.0
11 stars 1 forks source link

About plotting functions in `src/proteus/plot/ ` #143

Closed stefsmeets closed 2 weeks ago

stefsmeets commented 3 weeks ago

Hi all, I was wondering about the plot functions in src/proteus/plot/cpl_*.py. I know that some of these get run in the Proteus main loop to produce the plots.

But all of these also have entry points (if name == __main__), which indicates to me that they are also supposed to be run directly. Could you tell me how this is this meant to work?

I was thinking we could fold those into the proteus CLI to make these funcions more accessible.

e.g.

proteus plot interior --config init_coupler.toml 
# or
proteus plot sflux --config init_coupler.toml 

And at the same time, by structuring this a bit more, we could expose it via a python api:

from proteus import Proteus

handler = Proteus(config_path='init_coupler.toml')
handler.plot('interior', **kwargs)
# alternative
handler.plot_interior(**kwargs)

Let me know what you think.

nichollsh commented 2 weeks ago

I have been using the __main__ entry points as a way of plotting graphs from model outputs directly from the command line. This is useful when debugging the graphing routines, and also for when certain graphs are not automatically generated (e.g. when plotting frequency is set to zero).

Interacting with this through a cohesive CLI makes sense to me, although I can imagine this might create additional overhead?

stefsmeets commented 2 weeks ago

The overhead from the cli bit is minimal. The code will spend the most time reading/processing data and preparing the plots.

I'm also hoping that this will help make the plots more testable.

timlichtenberg commented 2 weeks ago

I just want to point out here quickly that it will be important that one can use and execute these plotting scripts standalone, without any overhead or additional packages to be installed, as is the case currently. For BSc/MSc/PhD students they serve as example of how to construct personalised plotting routines. So the idea is that the students can copy these scripts, and then "make them their own". Please ensure this capability stays.

stefsmeets commented 2 weeks ago

You mean, as in python src/proteus/plot/cpl_elements.py?

The additional packages being anything that already proteus depends on, correct?

stefsmeets commented 2 weeks ago

You can have a look at plots with what I had in mind:

# list available plots
$ proteus plot --list
Available plots:
interior global
# plot interior, global
$ proteus plot interior global --config init_coupler.toml
Plotting: global
Plotting: interior

I have only done interior and global for now, but the rest is not so difficult to do. I will make a PR later this week.

stefsmeets commented 2 weeks ago

With the PR we get direct api access to the plots. Ideas for follow-up: