Repository navigation
New features
- numpy reductions on a
SpeasyVariabletake negative axes and tuples of axes, refusekeepdims=Truewith a clear
message, and keep the column names when dimension 1 stays. - Indexing works along any dimension:
var[:, :, 3]drops the axis,var[:, :, 1:3]keeps part of it, with the
axis values and bin widths cut to match (record-varying axes per record). A variable without column names, such as
whatselandintegratereturn, takes positions and numpy'scolumn_inames:var[:, 0]. speasy.signal.reductionadds what numpy can't do along an axis:dimension(find an axis by name, or part of
one),sel(select by value, as in xarray, open-ended ranges included) andintegrate(value times bin width)
(docs: "Selecting and reducing axes").speasy quicklookapplies a product'sreducekey from the SciQLop template before plotting: a list of
operations (isel,sel,sum,mean,integrate) along named axes,
[{"op": "mean", "axis": "phi"}, ...], so a 3D particle distribution can be drawn as an energy spectrogram.
The key is checked when the template is loaded.speasy.plotting.sciqlop_template.apply_operationsand
OPERATIONSare public, for SciQLop.- ISTP axes keep their bin widths:
VariableAxis.delta_plus/delta_minuscome from the axis' DELTA_PLUS_VAR /
DELTA_MINUS_VAR, or from DELTA_PLUS / DELTA_MINUS holding the values (Cluster). A side the file doesn't give stays
None, andintegratethen asks for edges, as ISTP defines the two only as a pair. Data cached before has none, and
integratethen takes the widths from the midpoints between the axis values. - The time axis keeps the Epoch's measurement periods too:
VariableTimeAxis.delta_plus/delta_minusare
durations (timedelta64[ns], one per record), read in the delta's own UNITS, else in the Epoch's unit. MMS FPI fast
gives +4.5 s / -0 s, Cluster CIS 3D distributions +duration / -0 s. speasy.core.exceptionsholds Speasy's public exceptions, all derived fromSpeasyError. An unknown product
id now raisesUnknownProduct(orUnknownProvider,UnknownDataset,UnknownParameter,
UnknownVirtualProduct), still aValueError, from every provider. The existing exceptions keep their old
import paths and built-in bases. An unknown CSA dataset used to raise a bareKeyError.- A CEF (Cluster Exchange Format) codec, built on CEFast:
get_codec("cef")reads CEF 2.0 files, with their support axes (DEPEND_i), column names (LABEL_ior
REPRESENTATION_i), units and fill values. CEF attributes are also given their ISTP names (DISPLAY_TYPE,
VAR_TYPE,SI_conversion), so plots work as for CDF files. - CSA: the 1081 datasets the archive only serves as CEF are now listed and readable (auxiliary data, magnetic
footprints, L-star, MAARBLE wave products…). - CSA: data is downloaded as CEF by default, about twice as fast as CDF, which CSA converts on each request.
spz.config.csa.output_formatoroutput_format="CDF_ISTP"on a request switches back to CDF for the datasets
CSA serves as CDF. Each format keeps its own cache entries: data cached from CDF before is downloaded again as CEF.
CSA requests skip proxies older than 0.27.0, whose speasy can't take the format. get_data(..., force_refresh=True)downloads the data again even when the cache is up to date,
and stores the result in the cache. It works with every provider, and always bypasses the proxy
server.speasy.DataIndex(path), a persistent data index (#122): a folder that keeps exactly the data a
study used, never expires, and works offline.DataIndex.get_datadownloads only what the index
doesn't hold yet;refresh=Trueandupdate_all_data()download it again on request.
export_dataandimport_datahand an index to someone else as a single tar. It stores whatever
speasy.get_datagives (time series, datasets, timetables, catalogs), andDataIndex.get_data
takes the same arguments. Inside awith spz.DataIndex(path):block, plainspz.get_datagoes through the index,
so existing code becomes reproducible unchanged; it is back to normal when the block ends. Thespeasy index
command fills (fill, with the same ranges ascache warm), inspects, exports and imports one.numcodecsis now a dependency (except under Pyodide), so data from the community cache server
always comesblosccompressed. Thebloscextra is kept, empty, sospeasy[blosc]still
installs.speasy.core.proxy.blosc_arraysencodes numpy arrays in that same format, the inverse of
unblosc_arrays.- CDAWeb parameters in the inventory carry their
DEPEND_0, the name of their time variable, so
parameters sharing a time axis can be told apart from the inventory alone. - Direct archives (and
speasy.core.any_files) can read files from FTP servers: use anftp://
URL inurl_patternormaster_file. Folder listing (use_file_list,randomsplits) and
the file cache work as for HTTP. DataProvider.request_options(**kwargs), a classmethod, gives theget_dataoptions that change
the returned data, with their defaults filled in: the coordinate system for SSCWeb, the frame and
sampling for CDPP 3DView, and the output format, restricted period and template inputs for AMDA. It
works without starting the provider.speasy.core.dataprovider.provider_class(name)gives the
class registered under a provider name or alias.- CDAWeb waveform datasets stored as buckets (PSP FIELDS burst, SolO RPW TDS and LFR, Van Allen Probes
EMFISIS, TRACERS TS1/TS2 MSC, Voyager PWS) are served as flat time series with one timestamp per sample.
SolO RPW LFR variables are split per sampling rate (<variable>_F0,_F1,_F2), and the SolO RPW
waveform datasets missing from CDAWeb's inventory are added to it. - Virtual products:
speasy.virtual_products.register_virtual_product("virtual/<path>", function), or used as a
decorator, serves a local function as a product, throughspz.get_dataand the inventory tree, with optional
metaandlabels(docs: "Virtual products"). Packages ship them through aspeasy.virtual_productsentry
point;.pyfiles in the user'svirtual_productsfolder, and incore.user_vp_extra_dirs, are loaded by
import speasy, a broken one is skipped with a warning naming the file. A product that requests itself, at any
time range, is refused. - Virtual expressions: Python operators on inventory products (
+ - * / **, negation,abs) build an expression,
such as10 * B / N, without downloading anything. It is computed by calling it with a time range, or registered
as a virtual product. Products on different time axes raiseTimeAxisMismatchunless aligned with
speasy.virtual_products.resample(one regular grid) orinterpolate(the time axis of a reference product).
Fill values and values outside VALIDMIN/VALIDMAX become NaN first, and UNITS are kept when the operation preserves
them (docs: "Virtual expressions"). - A
speasycommand, runnable withuvx speasy:get(to a.cdf,.csvor.ncfile),
config show/set/reset/add/remove(with the source of each value, passwords masked, bad values refused),
providers list/enable/disable,archive validate/dirs,cache info,cache warm(prefetch products on
time ranges given on the command line, in a file, or by the events of a timetable or catalog),index(see
DataIndexabove) andquicklook(one image per day, month or year from a SciQLop plot template) (docs:
"Command line"). The config helpers it uses are inspeasy.configfor Python use. speasy.data_providers.generic_archive.validate_inventory_file(file, start_time, stop_time)checks a direct-archive
YAML file: unknown keys (with a "did you mean"), missing or invalid values, and optionally one fetch per dataset.
A broken file or dataset no longer shows up as an empty folder, or disables the whole archive provider: it costs only
itself, with a warning saying why.- A
hapiprovider serves every server of the official HAPI registry (the 15 servers of
https://github.com/hapi-server/servers):spz.get_data("hapi/<server>/<dataset>/<parameter>", start, stop)and
spz.inventories.tree.hapi.<server>. A server's catalog and each dataset's details load on first access, the
path shown by the tree works as a product string, and requests are split on each server's maximum duration. The
[HAPI]config section disables servers (CDAWeb, AMDA, CSA and SSCWeb are always left to their native providers)
and adds others. With speasy-proxy 0.27.0 or later, the tree and the data come through the proxy (docs: "HAPI
servers"). SpeasyVariable.to_dataarray()/SpeasyVariable.from_dataarray()andDataset.from_xarray()convert to and
from xarray: dims and coords are named after the axes, record-varying axes become time-dependent coords, columns a
coordinate, and ISTP UNITS, FILLVAL, VALIDMIN, VALIDMAX the CF attributes. xarray is the optionalspeasy[xarray]
extra.SpeasyVariable.with_labels()andwith_meta()give a new variable sharing the data, with other column names or
metadata.from_dataframeaccepts anyDatetimeIndex, timezone-aware or not, and pandas 3's microsecond ones.var[rows, columns]selects both at once, columns by name, position, slice or list.//,%anddivmod
work on variables like numpy'sfloor_divideandmod;-v,+vandabs(v)work too, and so does
variable + datetime.timedelta."2018-01-02" in eventchecks a single time.interpolate(ref, [a, None])
keeps theNonethatget_datagives for a failed product.get_datawarns when a product's time axis is not
sorted.- CDAWeb: the virtual variables
arr_slice,alternate_view(and itsflip_vertvariant) andcloneare
computed from the data files, as CDAWeb computes them, checked against its web service on every dataset using them.
Those products (FAST ESA energy spectra, IMAGE EUV, RBSP REPT...) no longer go to the web service. FAST files named
with their orbit number (%q) are found in the archive. - REIMEI ESA and ISA Level-2 counts from JAXA DARTS, under
archive/darts/REIMEI, read with a newreimei/l2
codec. Direct archives getlist_next_folderfor archives that file data in the next period's folder. speasy.core.codecs.has_codec(name)tells whether a codec is available.
Behavior changes
- CDAWeb data read from the archive takes its UNITS, SI_CONVERSION, FILLVAL, VALIDMIN and VALIDMAX from the data file
that holds the values, through pyistp 0.9.3; the master CDF still gives the other attributes. Where the two disagree,
these attributes change: MMS FPI fastEpoch_plus_varused to read as 4.5 ms, it is 4.5 s. get_codecraises aValueErrorlisting the registered codecs for an unknown name, instead of returning
None.merge()refuses variables whose samples differ in shape; it used to broadcast a 1-column variable into every
column. numpy's joining functions (np.concatenate,vstack,hstack...) on variables raise aTypeError
pointing tomerge().- SSCWeb raises with SSCWeb's reason when it rejects a request (a bad
coordinate_system), instead of returning
Noneafter three retries. - CSA: a range without data gives
None; other HTTP errors raise anIOErrorthat points at an outage. - AMDA: rejected credentials raise
InvalidCredentials, saying how to fix them, instead of disabling the whole
provider; public products keep working. - A request whose start is after its stop says to swap them, from
spz.get_dataand from every provider. - A bad value in the config file or the environment falls back to the default with a warning saying how to fix it, and
speasy config setrefuses one. Boolean entries take only true or false (maybeused to mean false). A cache or
index folder that can't be created disables it with a warning instead of failingimport speasy. - A direct-archive split rule Speasy doesn't know raises instead of returning
None.
Bug fixes
-
CDAWeb patched datasets (PSP FIELDS TDS waveforms among them) no longer crash on a file holding more time records
than data records, or the reverse: the records present in both are kept, with a warning naming the file. -
Picking columns of a spectrogram whose axis varies with time, such as
var[:, 1:3], cut the axis' records instead
of its columns and failed. -
The name of a numpy result showed
<built-in function input>for each plain argument:
np.power(b, 2)was namedpower(b, <built-in function input>). It is nowpower(b, 2). -
Slicing a variable by time:
var["2016-06-03":"2016-06-04"]silently returned the whole variable; strings now work, like inget_data;- a naive
datetimewas read in the computer's local time zone, so in Parisvar[datetime(2016, 6, 3):]
started at 22:00 the day before. Naive datetimes are UTC, like everywhere else in Speasy; - any other kind of bound raises
TypeErrorinstead of being ignored.
-
CDPP 3DView: when its list of coordinate frames could not be fetched,
get_datasilently replaced
the requested frame byJ2000. With 3DView down but the proxy or the local cache still serving
data, aGSErequest could returnJ2000positions. The requested frame is now always kept. -
The HAPI writers (
hapi/csv,hapi/binary) write headers that validate against the HAPI 3.2 schema:- a fill value is written as one number (
"-1e+31","NaN"), not as an array ("[-1e+31]");
a fill value no double can hold is dropped instead of aborting the write; startDate/stopDateare always written. They default to the span of the records, and new
start_date/stop_datearguments tosave_variablesset the dataset's full range;- an empty variable is written as a "no data" (1201) response, which needs
start_date/stop_date
(orwith_headers=False), instead of raisingIndexError; - timestamps keep their microseconds or nanoseconds instead of being cut to milliseconds;
- 64-bit integers too large for HAPI's 32-bit integers are written as doubles instead of wrapping around;
hapi/csvwrites missing values asNaNinstead of an empty field;- single-column variables are written as scalars, without the ambiguous
"size": [1]; - empty units become
null, bin units default to"dimensionless", and blank labels are left out;
per-element units are written as one string when they all agree, as an array when they match a
1-D size, and are dropped otherwise, instead of crashing; vectorComponentsare only written in a shape HAPI accepts for the parameter;- dimensions bins can't describe get
"centers": null: ISTP vector components (text labels), so
CDAWeb vectors can be written at all, and coordinate grids spanning several dimensions; - a time-varying axis spanning several dimensions is written with its full
sizeinstead of a
header that disagrees with its data; - bins follow the order of the array's dimensions, and the reader keeps a dimension without
centers as an index axis so the following axes stay on their own dimension; hapi/csvcan write arrays with more than one dimension besides time;hapi/csvcan read back a header-only "no data" file;- bin centers containing NaN or infinity are written as
nullinstead of invalid JSON; - the HAPI readers accept bins given only by their
ranges, centered on each range.
- a fill value is written as one number (
-
CDAWeb with the default
BEST(orFILE) access method passed on no cache option:
prefer_cache,disable_cacheanddisable_proxywere ignored, whether the data came from
the archive or from the web service fallback.prefer_cache=Truenow reaches the archive. -
Direct archives (CDAWeb's archive path included) honour
prefer_cachefor their folder listings
too: once the 12 h listing cache had expired, every request listed the folders again, which fails
offline. With an expired cache, a cached CDAWeb request now makes no network request at all, where
it made one listing plus aHEADrequest per file. -
CSA works behind an HTTP proxy (
HTTP_PROXY). It used to be disabled there because of an astroquery
bug (astropy/astroquery#3228). Its inventory is now fetched with speasy's own small TAP client
(speasy.core.tap), soastroqueryis no longer a dependency, along with the 14 packages only it
pulled in. In the CSA inventory, empty fields are nowNoneinstead of''. -
CDAWeb: cached data reaching past the end of a dataset's coverage was kept for 7 days, hiding data appended since.
It is now kept for one hour, as AMDA's already was. Concurrent requests for the same uncached range of CDAWeb or
CDPP 3DView are downloaded once instead of once per caller (#371). -
An empty fetch kept its cache locks, so any other thread or process asking for the same range waited 10 minutes.
-
A failed cache write (a full disk) threw away the data just downloaded; it now warns and returns it.
-
CDAWeb datasets whose master drops DEPEND_0 on record-varying support data (SOLO_L2_SWA-EAS-PAD-DEF) failed their
shape check; such axes are time dependent (#399). -
CDAWeb: variables a master lists but a data file lacks (MMS EPD-EIS) load as no data instead of raising
KeyError. Axes that don't fit the data (GOES12_EPHEMERIS_SSC, RBSPICE TOFXEH) are dropped, as CDAWeb does, instead
of failing the request. -
The archive no longer lists the variables CDAWeb masters declare virtual and only its web service computes: about 40
CDAWeb products that always returnedNone. A file whose name holds no valid date (Voyager 2 on May 32nd 1984) is
skipped with a warning instead of failing the request. -
netCDF files: numeric attributes stay numbers, so FILLVAL masking works and
clamp_with_nanno longer crashes on
VALIDMIN / VALIDMAX. -
AMDA:
get_dataworks on parameter components such asamda/imf(1), listed in the tree but refused as unknown.
The user's timetables, catalogs, derived and private parameters are cached per user: after switching accounts, the
previous user's lists were served for up to 15 minutes. A request AMDA reports as done but whose result file is
missing says it is a server-side problem, and failed requests log their reason as warnings. -
CDPP 3DView errors quote the server's answer, not only the HTTP status.
-
CSA: a wrong product id gives a clear error instead of a bare
assert. -
A proxy answer other than 200 (unknown product, server errors) looked like "no data", so the source was never asked.
It now falls back to the source with one warning. A failing proxy request no longer prints the raw exception. -
uiowaephtool: Hyperion trajectories returned
None(the server's code ishype); rows past a body's ephemeris
coverage held 1970 timestamps and junk values, they are dropped; Methone, Anthe, Pallene, Telesto and Helene end in
2050, not 2094. -
User codec files failed with
NameErrorwhen a function used a name defined in the same file. -
The cache is closed at interpreter exit, so an embedding host (Julia's PythonCall) no longer leaks its database.
-
SpeasyVariable:v[0]andv[-1]select one row, as documented; an unknown column raises aKeyErrorlisting the columns;- numpy functions taking lists of variables recursed forever;
np.add(v, 1, out=w)returnsw,np.add(v, 1, where=mask)no longer crashes, andnp.cumsum,
np.sortandnp.gradientalong time keep the time axis;np.asarray(v)gives the values;to_dataframe()/from_dataframe()keep the name and metadata;unit_applied()on a variable without UNITS gives dimensionless values instead of raising;replace_fillval_by_nan()andclamp_with_nan()on integer data say to passconvert_to_float=True
instead of numpy's "cannot convert float NaN to integer";repr()andstr()are readable outside IPython.
-
resample,interpolateand the filters give an empty result for an empty variable, and refuse values with 3 or
more dimensions with a clear error. -
Plotting: spectrograms without DISPLAY_TYPE (CSA) are drawn as colormaps instead of lines, and values with 3 or more
dimensions say how to reduce them.plot.colormap()on a vector points toplot.line(), and plotting a
spectrogram on a given Axes no longer leaks a pyplot figure. -
Catalog.append()names the item it refuses and its type. -
Codecs:
hapi/csvkeeps the full float64 precision (it wrote 7 digits);- the HAPI readers take the bytes
save_variablesreturns, and read labels back as column names; - the CDF and netCDF writers keep column names and default VAR_TYPE to
data, so a round trip gives the variable
back; they no longer add DEPEND_* entries to the variable's own metadata; - two variables whose time axes share a name but not their values are saved, where the CDF writer raised and the
netCDF writer gave the second one the first one's timestamps.
Dependencies
- pyistp 0.9.3 or later (see Behavior changes), pycdfpp 0.17.0 or later (CDAWeb virtual variables), pysciqlop-cache
0.4.2 (same on-disk layout, no migration). - New: cefast 0.2.2 or later (the CEF codec), cyclopts (the
speasycommand), msgspec (the data index), and
numcodecs, until now thebloscextra (except under Pyodide). - astroquery and the 14 packages only it pulled in are gone. xarray is the optional
xarrayextra.