Type: | Package |
Title: | IO Help for infraFDTD Model |
Version: | 0.6 |
Date: | 2017-10-30 |
Imports: | fields |
Suggests: | rNOMADS |
Author: | Jake Anderson |
Maintainer: | Jake Anderson <ajakef@gmail.com> |
Description: | Facilitates the generation of input files for infraFDTD and processes snapshot output. infraFDTD is a finite-difference model written by Keehoon Kim for simulating infrasound that considers topography and a 1-D atmosphere (see Kim et al., 2015 <doi:10.1002/2015GL064466>). |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
NeedsCompilation: | no |
Packaged: | 2017-10-31 05:29:39 UTC; jake |
Repository: | CRAN |
Date/Publication: | 2017-11-01 04:04:19 UTC |
IO Help for infraFDTD Model
Description
Facilitates the generation of input files for infraFDTD and processes snapshot output. infraFDTD is a finite-difference model written by Keehoon Kim for simulating infrasound that considers topography and a 1-D atmosphere (see Kim et al., 2015 <doi:10.1002/2015GL064466>).
Details
The DESCRIPTION file:
Package: | infraFDTD.assist |
Type: | Package |
Title: | IO Help for infraFDTD Model |
Version: | 0.6 |
Date: | 2017-10-30 |
Imports: | fields |
Suggests: | rNOMADS |
Author: | Jake Anderson |
Maintainer: | Jake Anderson <ajakef@gmail.com> |
Description: | Facilitates the generation of input files for infraFDTD and processes snapshot output. infraFDTD is a finite-difference model written by Keehoon Kim for simulating infrasound that considers topography and a 1-D atmosphere (see Kim et al., 2015 <doi:10.1002/2015GL064466>). |
License: | GPL (>=2) |
Index of help topics:
MakeSnapshotInfo First Step in Snapshot Conversion MakeSnapshots Convert Binary Snapshot Output to PNGs PrepFiles Generate Input Files for infraFDTD infraFDTD.assist-package IO Help for infraFDTD Model
Before running the infraFDTD model, generate the input files using PrepFiles. After running the model, binary snapshot files can be converted into png files by MakeSnapshotInfo and MakeSnapshots.
Author(s)
Jake Anderson
Maintainer: Jake Anderson <ajakef@gmail.com>
References
The infraFDTD code is available on request from Keehoon Kim at LLNL (kim84@llnl.gov) and is described in Kim et al. (2015) <doi:10.1002/2015GL064466>.
See Also
See package rNOMADS for help finding atmospheric profiles for given time/place.
First Step in Snapshot Conversion
Description
Helps convert binary snapshot output from infraFDTD into images. This function collects information from the snapshots to facilitate the conversion. It does NOT perform the conversion itself (see MakeSnapshots for that).
Usage
MakeSnapshotInfo(inputdir = "./snapshots", dframe = 20, N = 400, xs, ys,
zs, makesec1 = TRUE, makesec2 = TRUE, makesurf = TRUE)
Arguments
inputdir |
Directory containing snapshot files. |
dframe |
Snapshot interval in samples (difference between snapshot file numbers). |
N |
Number of snapshots. |
xs |
X source coordinates (m); can be a vector if multiple sources. |
ys |
Y source coordinates (m); can be a vector if multiple sources. |
zs |
Z source coordinates (m); can be a vector if multiple sources. |
makesec1 |
Logical: should section 1 snapshots be processed? |
makesec2 |
Logical: should section 2 snapshots be processed? |
makesurf |
Logical: should surface snapshots be processed? |
Details
inputdir must include all snapshot files as well as coord_sec1.txt, coord_sec2.txt, and coord_sur.txt.
MakeSnapshotInfo is fairly time-consuming, so it's separated from MakeSnapshots so that MakeSnapshots can be run repeatedly to test different graphical settings without having to re-calculate this information every time.
Value
A list of data to be passed to MakeSnapshots.
Author(s)
Jake Anderson; code is heavily modified from Keehoon Kim's original snapshot code.
See Also
MakeSnapshots
Examples
## Don't Run: (requires snapshot files)
## info = MakeSnapshotInfo('./snapshots', dframe = 20, N = 400,
## xs = 100, ys = 100, zs = 500)
## MakeSnapshots(info, outputdir = './anim', prefix = 'snapshot', dt = 0.1)
Convert Binary Snapshot Output to PNGs
Description
With the help of MakeSnapshotInfo, converts binary snapshot output files from infraFDTD to PNG format.
Usage
MakeSnapshots(info, outputdir = "./anim", prefix = "snapshot", nums =
1:info$N, dt = 0.1, makesec1 = TRUE, makesec2 = TRUE, makesurf = TRUE,
res = 96, fn_topomap = "topomap.png", width = 480, height = NaN, asp =
1, pointsize = 12)
Arguments
info |
Output of MakeSnapshotInfo(). |
outputdir |
Directory where PNG files should be written. |
prefix |
Prefix to use in output file names (e.g., outputdir/prefix_sec1_001.png). |
nums |
Vector of snapshot numbers to convert (default is all of them). |
dt |
Snapshot interval in seconds |
makesec1 |
Logical: should section 1 snapshots be converted? |
makesec2 |
Logical: should section 2 snapshots be converted? |
makesurf |
Logical: should surface snapshots be converted? |
res |
Resolution of output PNG files (see ?png). |
fn_topomap |
File name for topo map output. |
width |
Width of output images (pixels) |
height |
Optional: if blank, MakeSnapshots() will find the correct height given the image dimensions and asp. If set, forces the height of output images. |
asp |
Aspect ratio of images (default 1). |
pointsize |
Pointsize in output images (default 12). |
Details
Use a shell command like 'convert' (imagemagick, available in linux) to make a gif out of the stills.
Value
None, file output only.
Author(s)
Jake Anderson; code is heavily modified from Keehoon Kim's original.
See Also
MakeSnapshotInfo
Examples
## Don't Run: (requires snapshot files)
## info = MakeSnapshotInfo('./snapshots', dframe = 20, N = 400,
## xs = 100, ys = 100, zs = 500)
## MakeSnapshots(info, outputdir = './anim', prefix = 'snapshot', dt = 0.1)
Generate Input Files for infraFDTD
Description
infraFDTD requires text files defining the topography, atmospheric sound speed structure, atmospheric density structure, and station locations. PrepFiles generates these files from variables in R.
Usage
PrepFiles(X, sta, dh, fn_topo, fn_c, fn_rho, fn_sta, c = 335, rho = 1.2,
xlim = range(X$x), ylim = range(X$y), c_function = NA, rho_function =
NA, z_extent = NaN)
Arguments
X |
DEM. Must include elements x (vector), y (vector), z (matrix: nrow = length(x), ncol = length(y)) |
sta |
Station info. Must include elements x, y (vectors in meters, in same coordinate system as X). Station names are optionally stored in element sta. z is optional and should only be included if you want microphones in the air. If z is missing, all stations are located on surface. Otherwise, NaN elevations are located on the surface, and non-NaN elevations are preserved. |
dh |
Grid Spacing (m). |
fn_topo |
Output file name for DEM. |
fn_c |
Output file name for sound speed. |
fn_rho |
Output file name for density. |
fn_sta |
Output file name for stations. |
c |
Sound speed (m/s). If a scalar, sound speed is homogeneous in the model. If a vector with length equal to the number of vertical nodes in the model, sound speed varies vertically according to the vector (this is inconvenient; it's normally better to use c_function for a variable atmosphere). This input is ignored if c_function is provided. |
rho |
Density (kg/m^3). If a scalar, density is homogeneous in the model. If a vector with length equal to the number of vertical nodes in the model, density varies vertically according to the vector (this is inconvenient; it's normally better to use rho_function for a variable atmosphere). This input is ignored if rho_function is provided. |
xlim |
X limits of output DEM–must be contained within the boundaries of DEM. |
ylim |
Y limits of output DEM–must be contained within the boundaries of DEM. |
c_function |
Function giving sound speed as a function of height. Consider using approxfun() to generate this from an atmospheric profile. |
rho_function |
Function giving density as a function of height. Consider using approxfun() to generate this from an atmospheric profile. |
z_extent |
Vertical thickness of model (m); must be greater than total relief in model. |
Details
This function does not generate a param.h file; however, it does print values that can be copied to param.h by the user.
Consider using package rNOMADS to find the atmospheric profile.
Value
None; print and file output only.
Author(s)
Jake Anderson
Examples
## generate the DEM
data(volcano) # Maunga Whau (NZ) from built-in package "datasets"
DEM = list(x = 10 * 1:87, y = 10 * 1:61, z = volcano)
## choose the station locations
sta = list(x = c(100, 500), y = c(100, 500))
## show the topo map with stations
image(DEM, col = terrain.colors(20))
contour(DEM, add = TRUE)
points(sta, pch = 25, bg = 1)
## make the input files for infraFDTD, using the default homogeneous
## sound speed and density
PrepFiles(X = DEM, sta = sta, dh = 10, fn_topo = 'topo.txt', fn_c =
'c.txt', fn_rho = 'rho.txt', fn_sta = 'sta.txt')