write

method of dascore.io.rsf.core.RSFV1 source

write(
    self ,
    spool ,
    resource ,
    data_path = None,
    **kwargs ,
)

Write a patch to RSF format.

if no data_path is NOT specified, the header and binary will be packed together data_path needs to be bindata_file.rsf or /location/of/bindata_file.rsf (NO ‘@’)

resource needs to be hdr_file.rsf or /location/of/hdr_file.rsf

spool needs to have a single patch in it

for a datetime time axis i, o is 0.0, epoch holds the start time as an ISO 8601 UTC string with nanoseconds, and the legacy key ‘starttime’ holds it as float seconds since 1970; any other axis, including a time axis of offsets, holds its start in o

Parameters

Parameter Description
spool The input spool to convert to rsf, must have exactly one patch.
resource Path to create the rsf file
data_path If data and rsf header information are to be separate, the
location of the data file. Needs to be bindata_file.rsf or
/location/of/bindata_file.rsf (no ‘@’)
Note
  • Patch datatype is converted to float32 for compatibility with Madagascar (may be able to keep dtype in the future), with a DASCoreWarning when the data are not already float32
  • With data_path, the header’s in= holds the binary’s absolute path
  • Without data_path, the header ends with a blank line and the separator bytes 0x0c 0x0c 0x04 before the binary
  • Each attr that is set, except the ids and coordinate fields such as time_min, is one key=value line (a dict as quoted JSON), prefixed ‘dascore_’ when its name is an RSF key such as n1. An attr Madagascar would misread (an odd quote, a control character, a non-identifier name) is skipped with a DASCoreWarning.
  • Each history entry is a line ‘# dascore ’, with ‘=’ written as ‘:’ and control characters as spaces, so it never binds; it reads back with those substitutions.