MazamaScience / AirFireModeling

Utilities to ease merging of USFS AirFire model output and monitoring data.
0 stars 0 forks source link

Support BlueSky model 'grid' -> 'monitor' conversion #14

Closed hmrtn closed 5 years ago

hmrtn commented 5 years ago

grid_createMonitor() is a fundamental tool for AFM 0.1.

AFM 0.2 breaks this and therefore must be updated to support grid -> monitor conversion. It needs to perform, and it needs to do it well.

jonathancallahan commented 5 years ago

The software stack is:

grid_createMonitor() > grid_subsetByDistance() > grid_subsetByMask()

It is in grid_subsetByMask() where the "unraveling" of the matrix occurs, spatial metadata are added and the _wsmonitor objects are created.

This ability to create a mask and convert each grid cell under the mask into a time series has proven to be very useful.

Something else to keep in mind about the words subset vs. filter in function names.

When originally written, the PWFSLSmoke package adopted an older, base R subset mentality where arguments were passed in rather than R expressions). Since then, as seen in the AirSensor package, we have increasingly been adopting the dplyr::filter mentality. The difference looks like this:

# subset
a <- grid %>% grid_subset(xlim = c(-120,-110)

# filter
a <- grid %>% grid_filter(longitude > -120 & longitude < -110)

For gridded data, it probably makes more sense retain the subset style as we convert these into endpoint indices for accessing data from an array.

Elsewhere, especially when we are dealing with tibbles where every record has the fields used in the expression, we should adopt the filter style where it makes sense and is easily coded. We're trying to bridge to worlds here and we may need both types of functions. I just want to make sure that we create function names that reflect these different styles.