Read/Write Round Trip
Use write_weather when you want to export a cleaned PlantMeteo table back to disk. This is useful after standardizing raw files, checking variables, or building a weather table from an API and saving the result for reuse.
Read A Local File
using PlantMeteo
using Dates
file = joinpath(dirname(dirname(pathof(PlantMeteo))), "test", "data", "meteo.csv")
weather = read_weather(
file,
:temperature => :T,
:relativeHumidity => (x -> x ./ 100) => :Rh,
:wind => :Wind,
:atmosphereCO2_ppm => :Cₐ,
date_format = DateFormat("yyyy/mm/dd")
)
weather[1:3]| TimeStepTable{Atmosphere{(:date, :duration,...}(3 x 29): | |||||||||||||||||||||||||||||
| date | duration | T | Wind | P | Rh | Precipitations | Cₐ | e | eₛ | VPD | ρ | λ | γ | ε | Δ | clearness | Ri_SW_f | Ri_PAR_f | Ri_NIR_f | Ri_TIR_f | Ri_custom_f | hour_start | hour_end | temperature | relativeHumidity | Re_SW_f | wind | atmosphereCO2_ppm | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| DateTime | Dates.CompoundPeriod | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Time | Time | Float64 | Float64 | Float64 | Float64 | Float64 | |
| 1 | 2016-06-12T12:00:00 | 30 minutes | 25.0 | 1.0 | 101.325 | 0.6 | 0.0 | 380.0 | 1.90812 | 3.1802 | 1.27208 | 1.18389 | 2.44188e6 | 0.0675791 | 0.602345 | 0.190095 | 0.75 | Inf | Inf | Inf | Inf | Inf | 12:00:00 | 12:30:00 | 25.0 | 60.0 | 500.0 | 1.0 | 380.0 |
| 2 | 2016-06-12T12:30:00 | 30 minutes | 26.0 | 1.5 | 101.325 | 0.62 | 0.0 | 380.0 | 2.09238 | 3.37481 | 1.28243 | 1.17993 | 2.43951e6 | 0.0676446 | 0.610038 | 0.200215 | 0.75 | Inf | Inf | Inf | Inf | Inf | 12:30:00 | 13:00:00 | 26.0 | 62.0 | 500.0 | 1.5 | 380.0 |
| 3 | 2016-06-12T13:00:00 | 30 minutes | 25.3 | 1.5 | 101.325 | 0.58 | 0.0 | 380.0 | 1.87776 | 3.23752 | 1.35976 | 1.1827 | 2.44117e6 | 0.0675987 | 0.60088 | 0.193085 | 0.75 | Inf | Inf | Inf | Inf | Inf | 13:00:00 | 13:30:00 | 25.3 | 58.0 | 500.0 | 1.5 | 380.0 |
Write It Back To Disk
roundtrip = mktempdir() do tmp
out = joinpath(tmp, "weather_out.csv")
write_weather(out, weather)
reread = read_weather(out; duration = Dates.Minute)
(
out,
length(reread) == length(weather),
reread[1].T == weather[1].T,
metadatakeys(reread),
)
end("/tmp/jl_IcwIuP/weather_out.csv", true, true, ("duration", "altitude", "name", "latitude", "use", "file"))roundtrip[1]"/tmp/jl_IcwIuP/weather_out.csv"roundtrip[2]trueroundtrip[3]trueroundtrip[4]("duration", "altitude", "name", "latitude", "use", "file")By default, write_weather avoids writing variables that can be recomputed from core atmospheric inputs. That keeps exported files focused on the variables that need to be persisted.
When To Use This Guide
Use this workflow when you want to:
- keep a cleaned file for later simulations
- normalize metadata and variable names once, then reuse the result
- export weather built from a PlantMeteo workflow rather than rebuilding it every time