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

Usability improvements for Python-based workflows #55

Open
tcmetzger opened this issue Oct 11, 2024 · 1 comment
Open

Usability improvements for Python-based workflows #55

tcmetzger opened this issue Oct 11, 2024 · 1 comment
Assignees
Milestone

Comments

@tcmetzger
Copy link
Collaborator

tcmetzger commented Oct 11, 2024

The Python interface also makes pyRTE+RRTMGP easier to use in Python-based workflows. Specifically:

  • Establish conventions: define a set of conventions for gas names, temperatures, pressures, and potentially other physical quantities, based on FC standards Version 27 (http://cfconventions.org/Data/cf-standard-names/27/build/cf-standard-name-table.html), see Python front-end: Conventions for user facing code #47 for more details!
  • Inferring towards those conventions: Use xarray metadata to extract information about the data available in the xarray data set and make it accessible in a standardized way on the frontend (based on the established conventions)
  • Wrapping:
    • Update the Python interface to use verbs instead of nouns (solve_lw instead of lw_solver).
    • Add a rte.solve function that automatically infers which solver to use based on the user-provided input data and uses sensible defaults. Specifically, this automates the following two decisions:
      • Retain spectral detail or accumulate on the fly?
      • Is the problem a 1-parameter or 3-paramter problem?
    • Robert and team to provide documentation about how the Fortran interface handles inferring from user input and mapping these choices to the kernel arguments

Related to #47

@tcmetzger tcmetzger added this to the Phase 2 milestone Oct 11, 2024
@tcmetzger tcmetzger moved this from To Do to In progress in pyRTE Phase 2 Dec 18, 2024
@RobertPincus
Copy link
Member

I was looking at the current spellings with @sehnem. There are two places that seem more complicated to me than is ideal for users.

First: Here's how users make a map from the physical state of the atmosphere to a radiation problem

atmosphere = xr.load_dataset(atmosphere_path)

gas_optics_lw = load_gas_optics(gas_optics_file=GasOpticsFiles.LW_G256)
gas_optics_lw.gas_optics.compute(atmosphere, problem_type="absorption")

I would except something more like

gas_optics_lw = load_gas_optics(gas_optics_file=GasOpticsFiles.LW_G256)
gas_optics_lw.compute(atmosphere, problem_type="absorption")

@sehnem explained that the two dots are required because gas_optics_lw is actually a data set. This doesn't seem quite right - users need not know what the dataset is or what it contains, and they certainly shouldn't mess with the data, they just want to do the computation. Can we add code ("syntactic sugar"?) to streamline the user interaction? @brendancol may have opinions.

Second, solving the radiation problem for currently uses;

solver = RTESolver()
fluxes = solver.solve(atmosphere, add_to_input=False)

I'd really expect something like

fluxes = rte.solve(atmosphere, add_to_input=False)

i.e. no initialization of the solver, which simply gets imported from rte. Are there not other approaches to saving persistent information?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In progress
Development

No branches or pull requests

3 participants