Skip to content

Commit

Permalink
Change stream_data to stream, because it's obviously data
Browse files Browse the repository at this point in the history
  • Loading branch information
ctessum committed Nov 1, 2024
1 parent 39a37c7 commit 3c4b717
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions bench/runbenchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ using Dates

const fs = EarthSciData.GEOSFPFileSet("4x5", "A3dyn")
spatial_ref = "+proj=longlat +datum=WGS84 +no_defs"
const itp_stream = EarthSciData.DataSetInterpolator{Float64}(fs, "U", DateTime(2022, 5, 1), DateTime(2022, 5, 3), spatial_ref; stream_data=true)
const itp_nostream = EarthSciData.DataSetInterpolator{Float64}(fs, "U", DateTime(2022, 5, 1), DateTime(2022, 5, 3), spatial_ref; stream_data=false)
const itp_stream = EarthSciData.DataSetInterpolator{Float64}(fs, "U", DateTime(2022, 5, 1), DateTime(2022, 5, 3), spatial_ref; stream=true)
const itp_nostream = EarthSciData.DataSetInterpolator{Float64}(fs, "U", DateTime(2022, 5, 1), DateTime(2022, 5, 3), spatial_ref; stream=false)
const ts = DateTime(2022, 5, 1):Hour(1):DateTime(2022, 5, 3)
const lons = deg2rad.(-180.0:1:174)
const lats = deg2rad.(-90:1:85)
Expand Down
6 changes: 3 additions & 3 deletions src/geosfp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,11 @@ Domain options (as of 2022-01-30):
The native data type for this dataset is Float32.
`stream_data` specifies whether the data should be streamed in as needed or loaded all at once.
`stream` specifies whether the data should be streamed in as needed or loaded all at once.
See http://geoschemdata.wustl.edu/ExtData/ for current data domain options.
"""
function GEOSFP(domain::AbstractString, domaininfo::DomainInfo; name=:GEOSFP, stream_data=true)
function GEOSFP(domain::AbstractString, domaininfo::DomainInfo; name=:GEOSFP, stream=true)
filesets = Dict{String,GEOSFPFileSet}(
"A1" => GEOSFPFileSet(domain, "A1"),
"A3cld" => GEOSFPFileSet(domain, "A3cld"),
Expand All @@ -242,7 +242,7 @@ function GEOSFP(domain::AbstractString, domaininfo::DomainInfo; name=:GEOSFP, st
for varname varnames(fs, starttime)
dt = EarthSciMLBase.dtype(domaininfo)
itp = DataSetInterpolator{dt}(fs, varname, starttime, endtime,
domaininfo.spatial_ref; stream_data=stream_data)
domaininfo.spatial_ref; stream=stream)
dims = dimnames(itp)
coords = Num[]
for dim in dims
Expand Down
6 changes: 3 additions & 3 deletions src/load.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ data records for the times immediately before and after the current time step.
`varname` is the name of the variable to interpolate. `default_time` is the time to use when initializing
the interpolator. `spatial_ref` is the spatial reference system that the simulation will be using.
`stream_data` specifies whether the data should be streamed in as needed or loaded all at once.
`stream` specifies whether the data should be streamed in as needed or loaded all at once.
"""
mutable struct DataSetInterpolator{To,N,N2,FT,ITPT}
fs::FileSet
Expand All @@ -152,14 +152,14 @@ mutable struct DataSetInterpolator{To,N,N2,FT,ITPT}
initialized::Bool

function DataSetInterpolator{To}(fs::FileSet, varname::AbstractString,
starttime::DateTime, enddtime::DateTime, spatial_ref; stream_data=true) where {To<:Real}
starttime::DateTime, enddtime::DateTime, spatial_ref; stream=true) where {To<:Real}
metadata = loadmetadata(fs, starttime, varname)

# Download all of the data we will need.
check_times = starttime:DataFrequencyInfo(fs, starttime).frequency:enddtime
cpts = unique(vcat([DataFrequencyInfo(fs, t).centerpoints for t in check_times]...))
cache_size = 3
if !stream_data
if !stream
cache_size = max(sum([starttime <= t < enddtime for t in cpts]), 2)
end

Expand Down
6 changes: 4 additions & 2 deletions src/nei2016monthly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,14 @@ for this dataset is Float32.
`scale` is a scaling factor to apply to the emissions data. The default value is 1.0.
`stream` specifies whether the data should be streamed in as needed or loaded all at once.
NOTE: This is an interpolator that returns an emissions value by interpolating between the
centers of the nearest grid cells in the underlying emissions grid, so it may not exactly conserve the total
emissions mass, especially if the simulation grid is coarser than the emissions grid.
"""
function NEI2016MonthlyEmis(sector::AbstractString, domaininfo::DomainInfo; scale=1.0,
name=:NEI2016MonthlyEmis, stream_data=true)
name=:NEI2016MonthlyEmis, stream=true)
fs = NEI2016MonthlyEmisFileSet(sector)
starttime, endtime = EarthSciMLBase.tspan_datetime(domaininfo)
pvdict = Dict([Symbol(v) => v for v in EarthSciMLBase.pvars(domaininfo)]...)
Expand All @@ -168,7 +170,7 @@ function NEI2016MonthlyEmis(sector::AbstractString, domaininfo::DomainInfo; scal
for varname varnames(fs, starttime)
dt = EarthSciMLBase.dtype(domaininfo)
itp = DataSetInterpolator{dt}(fs, varname, starttime, endtime,
domaininfo.spatial_ref; stream_data=stream_data)
domaininfo.spatial_ref; stream=stream)
@constants zero_emis = 0 [unit = units(itp) / u"m"]
zero_emis = ModelingToolkit.unwrap(zero_emis) # Unsure why this is necessary.
eq = create_interp_equation(itp, "", t, [x, y],
Expand Down
6 changes: 3 additions & 3 deletions test/load_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ end

@testset "big cache" begin
@test_nowarn EarthSciData.DataSetInterpolator{Float32}(fs, "U", DateTime(2022, 5, 1), DateTime(2022, 5, 3),
spatial_ref; stream_data=false)
spatial_ref; stream=false)
end

itp = EarthSciData.DataSetInterpolator{Float32}(fs, "U", DateTime(2022, 5, 1), DateTime(2022, 5, 3),
spatial_ref; stream_data=true)
spatial_ref; stream=true)
dfi = EarthSciData.DataFrequencyInfo(fs, fs.start)

answerdata = [tv(fs, t) * v for t dfi.centerpoints, v [1.0, 0.5, 2.0]]
Expand Down Expand Up @@ -128,7 +128,7 @@ end

@testset "no stream" begin
itp = EarthSciData.DataSetInterpolator{Float32}(fs, "U", DateTime(2022, 5, 1),
DateTime(2022, 5, 2), spatial_ref; stream_data=false)
DateTime(2022, 5, 2), spatial_ref; stream=false)

uvals = zeros(Float32, length(times), length(xs))
answers = zeros(Float32, length(times), length(xs))
Expand Down

0 comments on commit 3c4b717

Please sign in to comment.