Skip to content

Commit b8a55e4

Browse files
Refactor sitemap and documentation; deprecate functions
- Updated sitemap.xml to remove and reorder URLs for better structure. - Changed documentation references from 'robspack-deprecated.R' to 'rtorf-deprecated.R' in multiple Rd files. - Created rtorf-deprecated.R to list deprecated functions and provide alternatives. - Added obs_foot function documentation for footprint processing. - Introduced rtorf-package.R for package metadata. - Deprecated several functions in favor of more efficient alternatives.
1 parent e117865 commit b8a55e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+372
-887
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ docs
77
inst/doc
88
/doc/
99
/Meta/
10+
11+
/.quarto/

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: rtorf
22
Type: Package
33
Title: 'rtorf' Tools for Observations, Receptors and Footprints
4-
Version: 3.1.0
4+
Version: 3.2.0
55
Authors@R: c(
66
person(given = "Sergio", family = "Ibarra-Espinosa",
77
role = c("aut", "cre"),
@@ -20,7 +20,7 @@ URL: https://github.com/noaa-gml/rtorf,
2020
BugReports: https://github.com/noaa-gml/rtorf/issues/
2121
Encoding: UTF-8
2222
RoxygenNote: 7.3.3
23-
Date: 2025-11-11
23+
Date: 2025-12-01
2424
Suggests:
2525
knitr,
2626
rmarkdown,

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export(obs_addzero)
99
export(obs_agg)
1010
export(obs_convolve)
1111
export(obs_find_receptors)
12+
export(obs_foot)
1213
export(obs_footname)
1314
export(obs_format)
1415
export(obs_freq)

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# NEWS
22

3+
### rtorf 3.1.0 (Release date: 2025-12-01)
4+
5+
Add obs_foot to read, process footprints parallel
6+
37
### rtorf 3.1.0 (Release date: 2025-11-11)
48

59
fix obs_hysplit_control. It was nor wokring for the last day of the month

R/11_obs_convolve.R

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,3 +411,130 @@ obs_convolve <- function(
411411
))
412412
}
413413
}
414+
415+
416+
#' obs_footprints
417+
#'
418+
#' This function returns a arrays (or list of arrays) of convolved footpritns with flux
419+
#'
420+
#' @param foot_path path for footprint (length 1).
421+
#' @param name_foot name of the footprint variable in the NetCDF file.
422+
#' @param flon name of lons
423+
#' @param flat name of lats
424+
#' @param time_foot Time of the footprints (in the name file) or third dimension
425+
#' @param fn string with function to aggregate convolved fluxes, e.g. `mean`, `sum`, `max`, etc.
426+
#' @param as_list Logical, to return list of arrays
427+
#' @param verbose Logical, to display more information
428+
#' @export
429+
#' @import ncdf4 data.table
430+
#' @examples \dontrun{
431+
#' # do not run
432+
#' }
433+
obs_foot <- function(
434+
foot_path = "AAA",
435+
name_foot = "foot1",
436+
flon = "foot1lon",
437+
flat = "foot1lat",
438+
time_foot,
439+
fn = NULL,
440+
as_list = FALSE,
441+
verbose = TRUE
442+
) {
443+
# footprint information
444+
445+
if (length(foot_path) != 1) {
446+
stop("foot_path must be a single string")
447+
}
448+
449+
if (verbose) {
450+
cat(paste0("Reading ", foot_path, "\n"))
451+
}
452+
453+
nc <- ncdf4::nc_open(foot_path)
454+
455+
if (verbose) {
456+
cf <- ncdf4::ncatt_get(nc, 0, "Conventions")$value
457+
if (any(grepl("CF", cf))) print(paste0("Footprint Conventions = ", cf))
458+
}
459+
460+
if (any(name_foot %in% names(nc$var))) {
461+
if (verbose) {
462+
cat(paste0("Reading ", name_foot, "\n"))
463+
}
464+
foot <- ncdf4::ncvar_get(nc, name_foot)
465+
} else {
466+
stop(paste0("Variable ", name_foot, " not found among: ", names(nc$var)))
467+
}
468+
469+
foot1lat <- ncdf4::ncvar_get(nc, flat)
470+
foot1lon <- ncdf4::ncvar_get(nc, flon)
471+
472+
ncdf4::nc_close(nc)
473+
474+
# footprint times
475+
476+
df_times_foot <- data.table::data.table(
477+
time_start = rep(time_foot, dim(foot)[3]) # 240
478+
)
479+
480+
seq_time_start <- time_start <- nf <- hr <- NULL
481+
df_times_foot[,
482+
seq_time_start := seq.POSIXt(
483+
time_start[1],
484+
length.out = dim(foot)[3],
485+
by = "-1 hour",
486+
tz = "UTC"
487+
)
488+
]
489+
# first time is the footprint time, ;last time, 240 hours in the past.
490+
# df_times_foot has time_start seq_time_start
491+
# seq_time_start has the time to match emissions
492+
493+
if (verbose) {
494+
cat(
495+
"footprints, from ",
496+
strftime(
497+
df_times_foot$seq_time_start[1],
498+
format = "%Y-%m-%d %H:%M:%S",
499+
tz = "UTC"
500+
),
501+
" to ",
502+
strftime(
503+
df_times_foot$seq_time_start[dim(foot)[3]],
504+
format = "%Y-%m-%d %H:%M:%S",
505+
tz = "UTC"
506+
),
507+
"\n"
508+
)
509+
}
510+
511+
dim_names <- list(
512+
paste0("lon_", sprintf("%02d", 1:dim(foot)[1])),
513+
paste0("lat_", sprintf("%02d", 1:dim(foot)[2])),
514+
strftime(
515+
df_times_foot$seq_time_start,
516+
format = "%Y-%m-%d %H:%M:%S",
517+
tz = "UTC"
518+
) # this can vary, what if I have hourly fluxes?, or m
519+
)
520+
521+
dimnames(foot) <- dim_names
522+
523+
if (!is.null(fn)) {
524+
foot <- apply(foot, c(1, 2), fn, na.rm = T)
525+
}
526+
527+
if (!as_list) {
528+
simplify2array(list(
529+
foot = foot
530+
)) -> out
531+
return(out)
532+
} else {
533+
return(list(
534+
foot = foot,
535+
lat = foot1lat,
536+
lon = foot1lon,
537+
time = if (!missing(fn)) time_foot else df_times_foot$seq_time_start
538+
))
539+
}
540+
}
File renamed without changes.

0 commit comments

Comments
 (0)