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

Examining when ice formation and breakup occurs #251

Open
dzrobert opened this issue Jul 18, 2019 · 10 comments
Open

Examining when ice formation and breakup occurs #251

dzrobert opened this issue Jul 18, 2019 · 10 comments

Comments

@dzrobert
Copy link

I used to use a command:
iceonoff_mod = mda.lakes::get_ice_onoff(ice_data, get_temp(nc_file))
to get ice information

This now gives me the following error:
Error in ice_runs[, "values"] : subscript out of bounds

Anyway to fix this so that I can compare actual and observed freeze and breakup dates?

@hdugan
Copy link
Collaborator

hdugan commented Jul 18, 2019

I'm not familiar with the mda.lakes package, but does
get_temp(nc_file) still work on its own?

@jordansread
Copy link
Member

Oh, I didn't realize this was an mda.lakes function. That package is pretty unsupported for general use...

The function is here. I'm guessing there is either a change w/ GLM v3 that isn't supported or part of the move to the updated get_var?

@dzrobert
Copy link
Author

Yes, that works fine. I was using the following series of commands to compare actual and measured ice freeze and breakup:
iceonoff_mod = mda.lakes::get_ice_onoff(ice_data, get_temp(nc_file))
#MODELED Ice Dates
iceonoff_mod
iceonoff_obs = read.csv('Green_ice19.csv', as.is=TRUE)
iceonoff_obs$on = as.POSIXct(iceonoff_obs$on)
iceonoff_obs$off = as.POSIXct(iceonoff_obs$off)
sprintf('Ice ON: %g mean diff mod - obs', mean(as.numeric(iceboth$on_mod - iceboth$on_obs, units='days')))
sprintf('Ice OFF: %g mean diff mod - obs', mean(as.numeric(iceboth$off_mod - iceboth$off_obs, units='days')))

sprintf('Ice ON: %g mean absolute diff', mean(abs(as.numeric(iceboth$on_mod - iceboth$on_obs, units='days'))))
sprintf('Ice OFF: %g mean absolute diff', mean(abs(as.numeric(iceboth$off_mod - iceboth$off_obs, units='days'))))

@hdugan
Copy link
Collaborator

hdugan commented Jul 18, 2019

The error is in the mda.lakes::get_ice_onoff function.
It was probably due to an update in the rle2 function.
The function is calling the wrong names from the rle2 output. They need to be
'value'
'start'
'stop'
'length'
NOT values starts stops lengths

@hdugan
Copy link
Collaborator

hdugan commented Jul 18, 2019

This is a nice function though - maybe it should be in glmtools?

@dzrobert
Copy link
Author

dzrobert commented Jul 19, 2019 via email

@jordansread
Copy link
Member

I'm worried about exposing it in the package because it can give you the wrong answer (it makes assumptions about ice dates relative to peak temperatures). I think it is right 99.9% of the time, but consider it to be more of an analysis method that you'd do on the data coming out of get_ice() (or _var) where you'd have control and visibility in the decision of when to declare on vs off.

Or perhaps we expose it but treat as experimental?

@pchanson
Copy link
Member

pchanson commented Jul 19, 2019 via email

@dzrobert
Copy link
Author

I would be OK working with an experimental package? Right now I am just trying to see if ice on and off dates are close, Rather than looking through the daily ice thicknesses, this was working great. Is there a way just to grab a few lines from mda.lakes that I can run?

@hdugan
Copy link
Collaborator

hdugan commented Jul 25, 2019

Dale, I forked the mda repo and fixed the function. You can use it here:

install_github('hdugan/mda.lakes')

Don't know if you want a pull request to the main repo

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

No branches or pull requests

4 participants