waternumbers / dynatop

Dynamic TOPMODEL
https://waternumbers.github.io/dynatop/
3 stars 6 forks source link

Format of forcing data #14

Closed waternumbers closed 4 years ago

waternumbers commented 5 years ago

I've run both Swindale and Kent through dynatopGIS now and all seems to be well - will load into GIS to check later.

You've run your example using the data file Brompton.rda I need to construct data files for the Kent so I can do a test run but I have to admit to confusion over R data structures and lists and how to put it all together. If I'm understanding my notes correctly, we have the model generated by dynatopGIS and I also need a PET time series (can I get away with zeros just for now?) and gridded rainfall. We used a test period of November 2017 for Decipher so I'll do the same. I have a raster containing the the IDs of 262 stations over the catchment which tell us which gauge to use for which cell. Is that the correct format? (hope that makes sense)

Dr. Ann Kretzschmar

Lancaster Environment Centre

Lancaster University

LA1 4YQ

kretzsch@exchange.lancs.ac.ukmailto:kretzsch@exchange.lancs.ac.uk

octopusann@me.commailto:octopusann@me.com

mobile: 07775-968315


From: Paul Smith notifications@github.com Sent: 02 July 2019 12:40:33 To: waternumbers/dynatopGIS Cc: Kretzschmar, Ann; Mention Subject: Re: [waternumbers/dynatopGIS] devtools::github_install fails (#1)

Great . It is really easy to get confused - if in doubt kill your r session and start again :) i do this multiple times a day....

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/waternumbers/dynatopGIS/issues/1?email_source=notifications&email_token=ADG6OVUGY7FWYM5E3IHHUNLP5M5DDA5CNFSM4H32LILKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZA7OKA#issuecomment-507639592, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADG6OVSIUO6KUMSWCKVPHULP5M5DDANCNFSM4H32LILA.

Originally posted by @octopusann in https://github.com/waternumbers/dynatopGIS/issues/1#issuecomment-507725034

waternumbers commented 5 years ago

Hi Ann,

Firstly appreciate the difference between data file formats and data object classes. R uses two main types of data file

See this link for further explanation

What you are seeing loaded in "Brompton.rda" is the saved workspace of data for the Brompton examples. What you need to create is an object of the eXtensible Time Series (xts) class containing the forcing data for use in the call to dynatop

There are lots of ways to create an xts object, see for example here. Try some of the commands listed to explore the xts object created in the vignette then try with your own data.

Remember that the names of the different series must match those specified in the precip and pet input columns in the HRU table and that the data should be equally spaced in time

cheers

Paul

octopusann commented 5 years ago

Thanks for your reply. I’ve managed to create the xts objects now – the problem seemed to be reading in from excel. Even though the date/time field looked ok, it obviously wasn’t so I manually generated a date/time sequence in r and it worked fine.

I’m now on the line of code just before the simulations that runs check_obs and am getting a message that saying missing series ‘rainpet’. Say I have 200 HRUS, does this mean I need 200 rainfall and 200 pet series with 200 headers for each for hillslope? That is how I have read it.

check_obs(obs,unique(unlist(model$hillslope[,c("precip_input","pet_input")]),

This is precip_input

model$hillslope$precip_input [1] "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" [19] "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" [37] "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" [55] "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" [73] "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" [91] "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" [109] "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" [127] "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" [145] "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" [163] "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" [181] "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain" "rain"

The odd thing however is that it won't let me use 200, only 198 or it errors. Obviously I'm missing something ...

model$hillslope$precip_input<-my_s Error in $<-.data.frame(*tmp*, precip_input, value = c("rain", "rain", : replacement has 200 rows, data has 198

What about the channel? I seem to have 11 values but I can’t work out where they have come from.

model$channel id area precip_input pet_input 1 1 263872.2247 rain pet 2 2 232222.4432 rain pet 3 3 208049.5607 rain pet 4 4 699681.7618 rain pet 5 5 176172.5389 rain pet 6 6 246121.6223 rain pet 7 7 621318.2880 rain pet 8 8 500182.2749 rain pet 9 9 8614.5393 rain pet 10 10 2909.9607 rain pet 11 11 154.5438 rain pet

Apologies for the long email, I have looked at the code and done lots of googling but have just managed to confuse myself even more! Now getting very frustrated from lack of understanding.

Dr. Ann Kretzschmar

Senior Research Associate Q-NFM

B505 LEC 1

Lancaster Environment Centre

Lancaster University

LA1 4YQ

From: Paul Smith notifications@github.com Sent: 09 July 2019 07:49 To: waternumbers/dynatop dynatop@noreply.github.com Cc: Kretzschmar, Ann a.kretzschmar@lancaster.ac.uk; Mention mention@noreply.github.com Subject: Re: [waternumbers/dynatop] Format of forcing data (#14)

Hi Ann,

Firstly appreciate the difference between data file formats and data object classes. R uses two main types of data file

See this linkhttps://stackoverflow.com/questions/21370132/r-data-formats-rdata-rda-rds-etc for further explanation

What you are seeing loaded in "Brompton.rda" is the saved workspace of data for the Brompton examples. What you need to create is an object of the eXtensible Time Series (xts) class containing the forcing data for use in the call to dynatop

There are lots of ways to create an xts object, see for example herehttps://www.datacamp.com/community/blog/r-xts-cheat-sheet. Try some of the commands listed to explore the xts object created in the vignette then try with your own data.

Remember that the names of the different series must match those specified in the precip and pet input columns in the HRU table and that the data should be equally spaced in time

cheers

Paul

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/waternumbers/dynatop/issues/14?email_source=notifications&email_token=ADG6OVXPYHQKOY3XH7LJ62LP6QYGPA5CNFSM4H7B7LJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZPI3CI#issuecomment-509513097, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADG6OVRXQTSHR3L536BVETLP6QYGPANCNFSM4H7B7LJA.

waternumbers commented 5 years ago

Totally what I was trying to avoid....keeping multiple identical columns of long time series is ugh...

The idea is for the HRU table to contain the names of the column/variable in the xts object. As many HRUs as you want can then use the same named column as input.

You need a xts object with two series one called rain, one called pet. Something like

dummy = data.frame(rain=runif(100),pet=runif(100))
dummy_dates = seq(as.POSIXct("2019-01-01 00:00:00"),
as.POSIXct("2019-01-31 00:00:00"),length=100)
input = xts::xts(dummy,order.by=dummy_dates)

will generate a fake input. Use head to look at it

head(input)

and you will see two named columns and the time stamps

                    rain      pet
2019-01-01 00:00:00 0.2304616 0.1600643
2019-01-01 07:16:21 0.1629886 0.2886101
2019-01-01 14:32:43 0.6143469 0.8021290
2019-01-01 21:49:05 0.5016364 0.1642457
2019-01-02 05:05:27 0.1881189 0.7897927
2019-01-02 12:21:49 0.4077149 0.5242150
octopusann commented 5 years ago

Ok, I agree about the multiple columns!! The duplicating headers bit came from Barry but seemed to make sense at the time and worked for SwareGill I think.

So if we have rainfall for several locations used by different HRUs, I would (somehow) be pointing the HRU to use the relevant rainfall column. Not doing so yet, just checking if my understanding is correct.

I have currently got rainfall TS for 250 odd locations, over the kent, to get it running I can obviously just pick one but ultimately they need to map onto the HRUs.

Ok will give it a go ….

Thanks

Dr. Ann Kretzschmar Senior Research Associate Q-NFM

B505 LEC 1

Lancaster Environment Centre Lancaster University LA1 4YQ

From: Paul Smith notifications@github.com Sent: 09 July 2019 10:04 To: waternumbers/dynatop dynatop@noreply.github.com Cc: Kretzschmar, Ann a.kretzschmar@lancaster.ac.uk; Mention mention@noreply.github.com Subject: Re: [waternumbers/dynatop] Format of forcing data (#14)

Totally what I was trying to avoid....keeping multiple identical columns of long time series is ugh...

The idea is for the HRU table to contain the names of the column/variable in the xts object. As many HRUs as you want can then use the same named column as input.

You need a xts object with two series one called rain, one called pet. Something like

dummy = data.frame(rain=runif(100),pet=runif(100))

dummy_dates = seq(as.POSIXct("2019-01-01 00:00:00"),

as.POSIXct("2019-01-31 00:00:00"),length=100)

input = xts::xts(dummy,order.by=dummy_dates)

will generate a fake input. Use head to look at it

head(input)

and you will see two named columns and the time stamps

                rain      pet

2019-01-01 00:00:00 0.2304616 0.1600643

2019-01-01 07:16:21 0.1629886 0.2886101

2019-01-01 14:32:43 0.6143469 0.8021290

2019-01-01 21:49:05 0.5016364 0.1642457

2019-01-02 05:05:27 0.1881189 0.7897927

2019-01-02 12:21:49 0.4077149 0.5242150

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/waternumbers/dynatop/issues/14?email_source=notifications&email_token=ADG6OVU27S3YQRHELMQHIYLP6RIAFA5CNFSM4H7B7LJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZPTZ2A#issuecomment-509557992, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADG6OVUX36TZAXDQUURLD63P6RIAFANCNFSM4H7B7LJA.

waternumbers commented 5 years ago

Yes; you would point an HRU to a different rainfall time series (column in the xts input data) by changing the value precip_input for that HRU in the HRU table to the name of the column in the xts input data

Will work for both channel and hillslope HRUs

octopusann commented 5 years ago

Got as far as the simulations now but its now telling me I have an error

Error in 1:ts$n_sub_step : NA/NaN argument

All the data is in 15 min timesteps so I didn't resample but after merging into one xts I ran

obs=my_xts

remove non-finite values

obs[!is.finite(obs)] <- 0

my_xts contains rain, pet and qobs

Just to clarify, which table are you referring to as the HRU table?

Dr. Ann Kretzschmar

Lancaster Environment Centre

Lancaster University

LA1 4YQ

kretzsch@exchange.lancs.ac.ukmailto:kretzsch@exchange.lancs.ac.uk

octopusann@me.commailto:octopusann@me.com

mobile: 07775-968315


From: Paul Smith notifications@github.com Sent: 09 July 2019 10:29:53 To: waternumbers/dynatop Cc: Kretzschmar, Ann; Mention Subject: Re: [waternumbers/dynatop] Format of forcing data (#14)

Yes; you would point an HRU to a different rainfall time series (column in the xts input data) by changing the value precip_input for that HRU in the HRU table to the name of the column in the xts input data

Will work for both channel and hillslope HRUs

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/waternumbers/dynatop/issues/14?email_source=notifications&email_token=ADG6OVVJLTVYJTL7ACF47L3P6RLBDA5CNFSM4H7B7LJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZPWD4Y#issuecomment-509567475, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADG6OVRTXMYKOXHHAZ3CXADP6RLBDANCNFSM4H7B7LJA.

waternumbers commented 5 years ago

Number of sub time steps in the solution is missing. These are computed using the output of the check_obs function.

What does

check_obs(my_xts)

return?

octopusann commented 5 years ago

check_obs(obs,unique(unlist(model$hillslope[,c("precip_input","pet_input")]),

$n_sub_step [1] 1

$sub_step [1] 0.25

Dr. Ann Kretzschmar

Lancaster Environment Centre

Lancaster University

LA1 4YQ

kretzsch@exchange.lancs.ac.ukmailto:kretzsch@exchange.lancs.ac.uk

octopusann@me.commailto:octopusann@me.com

mobile: 07775-968315


From: Paul Smith notifications@github.com Sent: 09 July 2019 11:00:57 To: waternumbers/dynatop Cc: Kretzschmar, Ann; Mention Subject: Re: [waternumbers/dynatop] Format of forcing data (#14)

Number of sub time steps in the solution is missing. These are computed using the output of the check_obs function.

What does

check_obs(my_xts)

return?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/waternumbers/dynatop/issues/14?email_source=notifications&email_token=ADG6OVRLF2MNA32OLM3YA2DP6ROVTA5CNFSM4H7B7LJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZPYZSA#issuecomment-509578440, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADG6OVWQ5WBDGAU6XUCJQ4TP6ROVTANCNFSM4H7B7LJA.

waternumbers commented 5 years ago

That looks OK. Are you trying to force the model to a different timestep in the simulation?

octopusann commented 5 years ago

Not as far as I know! This is the code - modified from the vignette

select the event period

event_period <- "2017-11-1 16:45:00 :2017-11-30 23:30:00"

recharge rate for initialization

initial_recharge <- as.numeric(obs["2017-11-1 16:45:00",'qobs'])

running the model

sim_1 <- dynatop(model,obs[event_period,],initial_recharge)

Dr. Ann Kretzschmar

Lancaster Environment Centre

Lancaster University

LA1 4YQ

kretzsch@exchange.lancs.ac.ukmailto:kretzsch@exchange.lancs.ac.uk

octopusann@me.commailto:octopusann@me.com

mobile: 07775-968315


From: Paul Smith notifications@github.com Sent: 09 July 2019 11:19:23 To: waternumbers/dynatop Cc: Kretzschmar, Ann; Mention Subject: Re: [waternumbers/dynatop] Format of forcing data (#14)

That looks OK. Are you trying to force the model to a different timestep in the simulation?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/waternumbers/dynatop/issues/14?email_source=notifications&email_token=ADG6OVWYZMR7LW6SPHXBOQLP6RQ2XA5CNFSM4H7B7LJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZP2H3A#issuecomment-509584364, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADG6OVXDN7ANO476SIXWVHDP6RQ2XANCNFSM4H7B7LJA.

waternumbers commented 5 years ago

Do those periods exist in the data? Can't suggest much more then the obvious unless you can give me a minimal reproducible example so i can step through the code. Or since you have it you could do this yourself?

octopusann commented 5 years ago

They should do(!). Thius is some of the data:

head(obs,20) rain pet qobs 2017-11-01 16:45:00 0.00 1e-05 2.04e-05 2017-11-01 17:00:00 0.00 1e-05 2.04e-05 2017-11-01 17:15:00 0.00 1e-05 2.04e-05 2017-11-01 17:30:00 0.00 1e-05 2.04e-05 2017-11-01 17:45:00 0.00 1e-05 2.04e-05 2017-11-01 18:00:00 0.00 1e-05 2.04e-05 2017-11-01 18:15:00 0.00 1e-05 2.02e-05 2017-11-01 18:30:00 0.00 1e-05 2.04e-05 2017-11-01 18:45:00 0.00 1e-05 2.04e-05 2017-11-01 19:00:00 0.00 1e-05 2.04e-05 2017-11-01 19:15:00 0.00 1e-05 2.04e-05 2017-11-01 19:30:00 0.00 1e-05 2.04e-05 2017-11-01 19:45:00 0.00 1e-05 2.04e-05 2017-11-01 20:00:00 0.04 1e-05 2.04e-05 2017-11-01 20:15:00 0.00 1e-05 2.04e-05 2017-11-01 20:30:00 0.05 1e-05 2.04e-05 2017-11-01 20:45:00 0.16 1e-05 2.04e-05 2017-11-01 21:00:00 0.00 1e-05 2.04e-05 2017-11-01 21:15:00 0.00 1e-05 2.04e-05 2017-11-01 21:30:00 0.00 1e-05 2.04e-05

and the end

tail(obs,20) rain pet qobs 2017-11-30 18:45:00 0 1e-05 3.56e-05 2017-11-30 19:00:00 0 1e-05 3.56e-05 2017-11-30 19:15:00 0 1e-05 3.56e-05 2017-11-30 19:30:00 0 1e-05 3.54e-05 2017-11-30 19:45:00 0 1e-05 3.56e-05 2017-11-30 20:00:00 0 1e-05 3.49e-05 2017-11-30 20:15:00 0 1e-05 3.49e-05 2017-11-30 20:30:00 0 1e-05 3.49e-05 2017-11-30 20:45:00 0 1e-05 3.49e-05 2017-11-30 21:00:00 0 1e-05 3.49e-05 2017-11-30 21:15:00 0 1e-05 3.46e-05 2017-11-30 21:30:00 0 1e-05 3.46e-05 2017-11-30 21:45:00 0 1e-05 3.43e-05 2017-11-30 22:00:00 0 1e-05 3.43e-05 2017-11-30 22:15:00 0 1e-05 3.43e-05 2017-11-30 22:30:00 0 1e-05 3.43e-05 2017-11-30 22:45:00 0 1e-05 3.41e-05 2017-11-30 23:00:00 0 1e-05 3.41e-05 2017-11-30 23:15:00 0 1e-05 3.41e-05 2017-11-30 23:30:00 0 1e-05 3.38e-05

I can't see anything amiss! The dates and times seem to be OK and there are the right number of them (2812). I do notice that rain changes to integer at around timestep 2500ish

I can send you data and code - I'm still struggling with trying to understand how r works, its getting better - down to thick mist from fog!!

Dr. Ann Kretzschmar

Lancaster Environment Centre

Lancaster University

LA1 4YQ

kretzsch@exchange.lancs.ac.ukmailto:kretzsch@exchange.lancs.ac.uk

octopusann@me.commailto:octopusann@me.com

mobile: 07775-968315


From: Paul Smith notifications@github.com Sent: 09 July 2019 11:30:41 To: waternumbers/dynatop Cc: Kretzschmar, Ann; Mention Subject: Re: [waternumbers/dynatop] Format of forcing data (#14)

Do those periods exist in the data? Can't suggest much more then the obvious unless you can give me a minimal reproducible example so i can step through the code. Or since you have it you could do this yourself?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/waternumbers/dynatop/issues/14?email_source=notifications&email_token=ADG6OVRYJCXHVML56T52SQ3P6RSFDA5CNFSM4H7B7LJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZP3DGQ#issuecomment-509587866, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADG6OVRGXNR4C4WZLZJMPQLP6RSFDANCNFSM4H7B7LJA.

octopusann commented 5 years ago

It looks like sim_time_step is getting overwritten in the routine dynatop. I've tried forcing it to use a specified time step and still get the same error.

ts=check_obs(obs,unique(unlist(model$hillslope[,c("precip_input","pet_input")]),

$n_sub_step [1] 1

$sub_step [1] 0.25

so ts has a value but if I now run

sim_2 <- dynatop(model,obs[event_period,],initial_recharge,sim_time_step=5/60) Error in 1:ts$n_sub_step : NA/NaN argument

it errors again

This is the dynatop code i'm using

dynatop <- function(model,obs_data,initial_recharge=NA,sim_time_step=NULL, use_states=FALSE){

check input and get model timestep

ts <- check_obs(obs_data,
                unique( c(unlist(model$hillslope[,c("precip_input","pet_input")]),
                          unlist(model$channel[,c("precip_input","pet_input")]))),
                       sim_time_step)

Running this alone gives

ts <- check_obs(obs_data,

$n_sub_step [1] NA

$sub_step [1] NA

I can see what it should do but it doesn't seem to be doing it!

Dr. Ann Kretzschmar

Lancaster Environment Centre

Lancaster University

LA1 4YQ

kretzsch@exchange.lancs.ac.ukmailto:kretzsch@exchange.lancs.ac.uk

octopusann@me.commailto:octopusann@me.com

mobile: 07775-968315


From: Paul Smith notifications@github.com Sent: 09 July 2019 11:30:41 To: waternumbers/dynatop Cc: Kretzschmar, Ann; Mention Subject: Re: [waternumbers/dynatop] Format of forcing data (#14)

Do those periods exist in the data? Can't suggest much more then the obvious unless you can give me a minimal reproducible example so i can step through the code. Or since you have it you could do this yourself?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/waternumbers/dynatop/issues/14?email_source=notifications&email_token=ADG6OVRYJCXHVML56T52SQ3P6RSFDA5CNFSM4H7B7LJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZP3DGQ#issuecomment-509587866, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADG6OVRGXNR4C4WZLZJMPQLP6RSFDANCNFSM4H7B7LJA.

waternumbers commented 5 years ago

Sorry it is impossible to debug like this there are to many unknowns. Please put the xts data and model somewhere I can access then I'll have a look.On 9 Jul 2019 14:33, octopusann notifications@github.com wrote:It looks like sim_time_step is getting overwritten in the routine dynatop. I've tried forcing it to use a specified time step and still get the same error.

ts=check_obs(obs,unique(unlist(model$hillslope[,c("precip_input","pet_input")]),

ts

$step

[1] 0.25

$n_sub_step

[1] 1

$sub_step

[1] 0.25

so ts has a value but if I now run

sim_2 <- dynatop(model,obs[event_period,],initial_recharge,sim_time_step=5/60)

Error in 1:ts$n_sub_step : NA/NaN argument

it errors again

This is the dynatop code i'm using

dynatop <- function(model,obs_data,initial_recharge=NA,sim_time_step=NULL, use_states=FALSE){

# check input and get model timestep

ts <- check_obs(obs_data,

                unique( c(unlist(model$hillslope[,c("precip_input","pet_input")]),

                          unlist(model$channel[,c("precip_input","pet_input")]))),

                       sim_time_step)

Running this alone gives

ts <- check_obs(obs_data,

ts

$step

[1] NA

$n_sub_step

[1] NA

$sub_step

[1] NA

I can see what it should do but it doesn't seem to be doing it!

Dr. Ann Kretzschmar

Lancaster Environment Centre

Lancaster University

LA1 4YQ

kretzsch@exchange.lancs.ac.ukmailto:kretzsch@exchange.lancs.ac.uk

octopusann@me.commailto:octopusann@me.com

mobile: 07775-968315


From: Paul Smith notifications@github.com

Sent: 09 July 2019 11:30:41

To: waternumbers/dynatop

Cc: Kretzschmar, Ann; Mention

Subject: Re: [waternumbers/dynatop] Format of forcing data (#14)

Do those periods exist in the data? Can't suggest much more then the obvious unless you can give me a minimal reproducible example so i can step through the code. Or since you have it you could do this yourself?

You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHubhttps://github.com/waternumbers/dynatop/issues/14?email_source=notifications&email_token=ADG6OVRYJCXHVML56T52SQ3P6RSFDA5CNFSM4H7B7LJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZP3DGQ#issuecomment-509587866, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADG6OVRGXNR4C4WZLZJMPQLP6RSFDANCNFSM4H7B7LJA.

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or mute the thread.

octopusann commented 5 years ago

Ok understood. I really have tried to sort it myself, honest!! I'm attaching the R workspace file from a run of the code which I will also attach.

Appears to run OK down to line 141

Thanks for your help. 😊

Heading home soon so hope this is enough, if not, I will be in bright and early tomorrow (!)

Dr. Ann Kretzschmar

Lancaster Environment Centre

Lancaster University

LA1 4YQ

kretzsch@exchange.lancs.ac.ukmailto:kretzsch@exchange.lancs.ac.uk

octopusann@me.commailto:octopusann@me.com

mobile: 07775-968315


From: Paul Smith notifications@github.com Sent: 09 July 2019 16:00:31 To: waternumbers/dynatop Cc: Kretzschmar, Ann; Mention Subject: Re: [waternumbers/dynatop] Format of forcing data (#14)

Sorry it is impossible to debug like this there are to many unknowns. Please put the xts data and model somewhere I can access then I'll have a look.On 9 Jul 2019 14:33, octopusann notifications@github.com wrote:It looks like sim_time_step is getting overwritten in the routine dynatop. I've tried forcing it to use a specified time step and still get the same error.

ts=check_obs(obs,unique(unlist(model$hillslope[,c("precip_input","pet_input")]),

$n_sub_step [1] 1

$sub_step [1] 0.25

so ts has a value but if I now run

sim_2 <- dynatop(model,obs[event_period,],initial_recharge,sim_time_step=5/60) Error in 1:ts$n_sub_step : NA/NaN argument

it errors again

This is the dynatop code i'm using

dynatop <- function(model,obs_data,initial_recharge=NA,sim_time_step=NULL, use_states=FALSE){

check input and get model timestep

ts <- check_obs(obs_data, unique( c(unlist(model$hillslope[,c("precip_input","pet_input")]), unlist(model$channel[,c("precip_input","pet_input")]))), sim_time_step)

Running this alone gives

ts <- check_obs(obs_data,

$n_sub_step [1] NA

$sub_step [1] NA

I can see what it should do but it doesn't seem to be doing it!

Dr. Ann Kretzschmar

Lancaster Environment Centre

Lancaster University

LA1 4YQ

kretzsch@exchange.lancs.ac.ukmailto:kretzsch@exchange.lancs.ac.uk

octopusann@me.commailto:octopusann@me.com

mobile: 07775-968315


From: Paul Smith notifications@github.com Sent: 09 July 2019 11:30:41 To: waternumbers/dynatop Cc: Kretzschmar, Ann; Mention Subject: Re: [waternumbers/dynatop] Format of forcing data (#14)

Do those periods exist in the data? Can't suggest much more then the obvious unless you can give me a minimal reproducible example so i can step through the code. Or since you have it you could do this yourself?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/waternumbers/dynatop/issues/14?email_source=notifications&email_token=ADG6OVRYJCXHVML56T52SQ3P6RSFDA5CNFSM4H7B7LJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZP3DGQ#issuecomment-509587866, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADG6OVRGXNR4C4WZLZJMPQLP6RSFDANCNFSM4H7B7LJA.

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/waternumbers/dynatop/issues/14?email_source=notifications&email_token=ADG6OVT5JWK6PM3NGDY3DQ3P6SRY7A5CNFSM4H7B7LJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZQRJ7Y#issuecomment-509678847, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADG6OVWQRNPYEOZSVI6RJN3P6SRY7ANCNFSM4H7B7LJA.

waternumbers commented 5 years ago

No worries already finished for the day. Will try to look tomorrowOn 9 Jul 2019 16:35, octopusann notifications@github.com wrote:Ok understood. I really have tried to sort it myself, honest!! I'm attaching the R workspace file from a run of the code which I will also attach.

Appears to run OK down to line 141

Thanks for your help. 😊

Heading home soon so hope this is enough, if not, I will be in bright and early tomorrow (!)

Dr. Ann Kretzschmar

Lancaster Environment Centre

Lancaster University

LA1 4YQ

kretzsch@exchange.lancs.ac.ukmailto:kretzsch@exchange.lancs.ac.uk

octopusann@me.commailto:octopusann@me.com

mobile: 07775-968315


From: Paul Smith notifications@github.com

Sent: 09 July 2019 16:00:31

To: waternumbers/dynatop

Cc: Kretzschmar, Ann; Mention

Subject: Re: [waternumbers/dynatop] Format of forcing data (#14)

Sorry it is impossible to debug like this there are to many unknowns. Please put the xts data and model somewhere I can access then I'll have a look.On 9 Jul 2019 14:33, octopusann notifications@github.com wrote:It looks like sim_time_step is getting overwritten in the routine dynatop. I've tried forcing it to use a specified time step and still get the same error.

ts=check_obs(obs,unique(unlist(model$hillslope[,c("precip_input","pet_input")]),

ts

$step

[1] 0.25

$n_sub_step

[1] 1

$sub_step

[1] 0.25

so ts has a value but if I now run

sim_2 <- dynatop(model,obs[event_period,],initial_recharge,sim_time_step=5/60)

Error in 1:ts$n_sub_step : NA/NaN argument

it errors again

This is the dynatop code i'm using

dynatop <- function(model,obs_data,initial_recharge=NA,sim_time_step=NULL, use_states=FALSE){

check input and get model timestep

ts <- check_obs(obs_data,

unique( c(unlist(model$hillslope[,c("precip_input","pet_input")]),

unlist(model$channel[,c("precip_input","pet_input")]))),

sim_time_step)

Running this alone gives

ts <- check_obs(obs_data,

ts

$step

[1] NA

$n_sub_step

[1] NA

$sub_step

[1] NA

I can see what it should do but it doesn't seem to be doing it!

Dr. Ann Kretzschmar

Lancaster Environment Centre

Lancaster University

LA1 4YQ

kretzsch@exchange.lancs.ac.ukmailto:kretzsch@exchange.lancs.ac.uk

octopusann@me.commailto:octopusann@me.com

mobile: 07775-968315


From: Paul Smith notifications@github.com

Sent: 09 July 2019 11:30:41

To: waternumbers/dynatop

Cc: Kretzschmar, Ann; Mention

Subject: Re: [waternumbers/dynatop] Format of forcing data (#14)

Do those periods exist in the data? Can't suggest much more then the obvious unless you can give me a minimal reproducible example so i can step through the code. Or since you have it you could do this yourself?

You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHubhttps://github.com/waternumbers/dynatop/issues/14?email_source=notifications&email_token=ADG6OVRYJCXHVML56T52SQ3P6RSFDA5CNFSM4H7B7LJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZP3DGQ#issuecomment-509587866, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADG6OVRGXNR4C4WZLZJMPQLP6RSFDANCNFSM4H7B7LJA.

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or mute the thread.

You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHubhttps://github.com/waternumbers/dynatop/issues/14?email_source=notifications&email_token=ADG6OVT5JWK6PM3NGDY3DQ3P6SRY7A5CNFSM4H7B7LJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZQRJ7Y#issuecomment-509678847, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADG6OVWQRNPYEOZSVI6RJN3P6SRY7ANCNFSM4H7B7LJA.

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or mute the thread.

waternumbers commented 4 years ago

Stale issue. Please reopen an new issue if you experience the problem again