πΎ Exporting Dataο
SounderPy clean_data profiles can be exported for use outside the plotting
API. The current file-writing helper supports:
CSV;
SHARPpy/NSHARP-style sounding files;
CM1
input_sounding-style files.
Exports are created with:
spy.to_file(
file_type,
clean_data,
filename=...,
)
Retrieve an Example Profileο
import sounderpy as spy
data = spy.get_obs_data(
"OAX",
"2014", "06", "16", "18",
hush=True,
)
CSV Exportο
CSV is useful for spreadsheets, pandas, R, or general data exchange.
spy.to_file(
"csv",
data,
filename="oax_20140616_18z.csv",
)
The CSV contains the core sounding fields:
p
z
T
Td
u
v
Units are removed when the values are written, so retain the SounderPy variable definitions when using the file elsewhere:
Column |
Variable |
SounderPy unit |
|---|---|---|
|
Pressure |
hPa |
|
Height |
m |
|
Temperature |
degC |
|
Dewpoint |
degC |
|
U-component wind |
knots |
|
V-component wind |
knots |
Read a SHARPpy File Back into SounderPyο
SounderPy also provides from_sharppy():
data = spy.from_sharppy(
"oax_20140616_18z.snd"
)
The imported file is converted back into a SounderPy-style dictionary.
Depending on the source file, additional site metadata or plot titles may need to be supplied before producing a fully annotated SounderPy figure.
CM1 Exportο
A SounderPy profile can be converted into CM1 input_sounding format:
spy.to_file(
"cm1",
data,
filename="input_sounding",
)
The exporter derives the thermodynamic quantities used by CM1 and writes the profile in CM1 input format.
AGL Height Handling for CM1ο
The convert_to_AGL argument controls whether exported CM1 vertical heights
are converted to above-ground-level values.
Default:
spy.to_file(
"cm1",
data,
filename="input_sounding",
convert_to_AGL=True,
)
To retain the profileβs existing height values:
spy.to_file(
"cm1",
data,
filename="input_sounding",
convert_to_AGL=False,
)
Default Filenameο
filename is optional in the Python API. If omitted, SounderPy uses its
default output name:
spy.to_file(
"csv",
data,
)
For reproducible workflows, explicitly providing a filename is recommended.
CLI Exportο
The CLI can infer output format from recognized filename extensions.
CSV:
sounderpy obs OAX 2014-06-16 18 \
--output oax.csv
SHARPpy:
sounderpy obs OAX 2014-06-16 18 \
--output oax.snd
CM1:
sounderpy obs OAX 2014-06-16 18 \
--output input_sounding.cm1
You can also specify the format explicitly:
sounderpy obs OAX 2014-06-16 18 \
--output profile.dat \
--format csv
Export and Plot in One CLI Commandο
The CLI retrieves the profile once and can use the result for several outputs:
sounderpy obs OAX 2014-06-16 18 \
--output oax.csv \
--plot sounding \
--map-zoom 0 \
--plot-file oax.png
Choosing an Export Formatο
Use CSV when:
you want a simple tabular file;
you plan to use pandas, spreadsheets, R, or another analysis tool.
Use SHARPpy when:
you want a conventional sounding-text format;
you want compatibility with SHARPpy-style workflows.
Use CM1 when:
you are preparing an idealized CM1 simulation;
you want to turn a retrieved or observed SounderPy profile into model input.
Next Stepsο
Continue to Command Line Workflows for shell-based retrieval, plotting, JSON, and batch examples.
See also: