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

Meanfield arrays are not converted back to native units. #32

Closed
rplzzz opened this issue Nov 3, 2019 · 1 comment
Closed

Meanfield arrays are not converted back to native units. #32

rplzzz opened this issue Nov 3, 2019 · 1 comment
Labels

Comments

@rplzzz
Copy link
Contributor

rplzzz commented Nov 3, 2019

In generate.TP.fullgrids, the mean field is not converted back to natural units. The generated fields are converted here:
https://github.com/JGCRI/fldgen/blob/master/R/generateTPfullgrids.R#L106-L123

It would be an easy fix to make this conversion on lines 110 and 119, but first we have to make sure that there isn't anywhere else where we assume that it hasn't been converted.

@rplzzz rplzzz added the bug label Nov 3, 2019
@abigailsnyder
Copy link
Contributor

Not actually an issue - mean fields are added to the residuals in lines 100-102 https://github.com/JGCRI/fldgen/blob/master/R/generateTPfullgrids.R#L100-L102
and then that whole thing is what gets converted to native units in https://github.com/JGCRI/fldgen/blob/master/R/generateTPfullgrids.R#L106-L123

In trainTP, values get converted (https://github.com/JGCRI/fldgen/blob/master/R/trainTP.R#L149-L166) before the mean field is calculated (https://github.com/JGCRI/fldgen/blob/master/R/trainTP.R#L188-L192).
Precip as an example:
We convert full precip to full logP (https://github.com/JGCRI/fldgen/blob/master/R/trainTP.R#L160-L166). We take the mean field and residuals from that data (https://github.com/JGCRI/fldgen/blob/master/R/trainTP.R#L192), so the mean field stored in the trained emulator is in units of logP and the residuals generated are in units of logP. In other words $log(P) = mean + resid <=> P = exp(mean + resid)$
That means the reconstruction function called on lines 89 and 90 of generateTPfullgrids is operating on logP and resulting in logP mean fields.
So when we add residuals and mean fields together on lines 100-102, we have logP full fields. When we go back to native units on line 106-123, the operation being done is then $exp(mean + resid)$ as we want.

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

No branches or pull requests

2 participants