-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmet_store_info.R
43 lines (40 loc) · 1.57 KB
/
met_store_info.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Insert info about this event into database
# attach a property showing the path to the original raster file
# attach a property with a web URL to the origina raster file
basepath='/var/www/R';
library("lubridate")
source("/var/www/R/config.R")
# Accepting command arguments:
argst <- commandArgs(trailingOnly = T)
if (length(argst) < 6) {
message("Use: Rscript met_store_info.R scenario coverage_hydrocode coverage_bundle coverage_ftype model_version met_file")
message("Ex: Rscript met_store_info.R nldas2 N5113 landunit cbp6_landseg met_file")
q('n')
}
scenario_name <- argst[1]
coverage_hydrocode <- argst[2]
coverage_bundle <- argst[3]
coverage_ftype <- argst[4]
model_version <- argst[5]
met_file <- argst[6]
# load the feature -- get feature hydroid
# find the dh_timeseries_weather record for this event
# attach an image property to the record
# return
message(paste("Searching for feature hydrocode =", coverage_hydrocode,"with ftype",coverage_ftype))
feature <- RomFeature$new(
ds,
list(
hydrocode=coverage_hydrocode,
ftype=coverage_ftype,
bundle=coverage_bundle
),
TRUE
)
# this will create or retrieve a model scenario to house this summary data.
model <- om_model_object(ds, feature, model_version)
# if a matching model does not exist, this will go ahead and create one
scenario <- om_get_model_scenario(ds, model, scenario_name)
met_data <- read.table(met_file, header = TRUE, sep=",")
numrecs <- nrow(met_data)
vahydro_post_metric_to_scenprop(scenario$pid, 'om_class_Constant', NULL, 'num_records', numrecs, ds)