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

Generalize creation of variables in models/ed/R/model2netcdf.ED2.R #2102

Open
serbinsh opened this issue Sep 14, 2018 · 7 comments
Open

Generalize creation of variables in models/ed/R/model2netcdf.ED2.R #2102

serbinsh opened this issue Sep 14, 2018 · 7 comments

Comments

@serbinsh
Copy link
Member

Is your feature request related to a problem? Please describe.
Based on this conversation:
#2098 (comment)

Currently, both output conversion and ncvar definitions are numerically hard-coded in the function put_T_values and put_E_values. This works but uses "s" to offset the index by the length of existing variables between -T-, -E-, and -S- outputs. As pointed out by @ashiklom this could lead to later challenges when adding in more variables or if the order is changed. It would be preferable to access both by name from a list of vars or other.

Describe the solution you'd like
#2098 (comment)

Access outputs and variables by name

Putting this here to open a discussion about this. @istfer is the best person to provide context for this before we make anymore changes.

@istfer
Copy link
Contributor

istfer commented Sep 14, 2018

we access standard netcdf file variables by name (the ones created by model2netcdf) if needed, iirc we don't assume a particular order anywhere after this. So, unless ED code changes (e.g. some vars in the middle are no longer outputted), adding more variables in model2netcdf with the number-wise approach should be trivial

but as I mentioned on the PR, I'm perfectly fine with extending nc_var list by name 👍

@serbinsh serbinsh mentioned this issue Sep 18, 2018
7 tasks
@serbinsh
Copy link
Member Author

@istfer OK, that makes sense. I wrote this issue based on comments in the PR and not having a full appreciation of your refactor. Not really sure what is best here but I'm sure we can come to some compromise.

@github-actions
Copy link

This issue is stale because it has been open 365 days with no activity.

@infotroph
Copy link
Member

@serbinsh @istfer is this issue still active?

@istfer
Copy link
Contributor

istfer commented Apr 11, 2020

I think we still have s and numbers in there. I'll defer to other people who are currently actively working with ED on whether to close or implement this

@Aariq Aariq self-assigned this Nov 15, 2022
@Aariq
Copy link
Collaborator

Aariq commented Nov 15, 2022

I think I'm going to need to dig back into this function so I'll check this out. If I remember correctly, it's still quite fragile.

@Aariq
Copy link
Collaborator

Aariq commented Nov 15, 2022

I think part of the solution here is to use append() instead of assigning to specific indexes.

e.g. instead of

  nc_var[[s + 6]] <- ncdf4::ncvar_def("GPP", units = "kg C m-2 s-1", dim = list(lon, lat, t), missval = -999, 
                                    longname = "Gross Primary Productivity")

do:

  nc_var <- append(nc_var, ncdf4::ncvar_def("GPP", units = "kg C m-2 s-1", dim = list(lon, lat, t), missval = -999, 
                                    longname = "Gross Primary Productivity"))

@Aariq Aariq removed their assignment Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants