Patch Conversions
Although DASCore provides much of the functionality needed for DFOS processing, it is not intended to do everything, and other libraries may be better suited for specific tasks. In addition to making it simple to access the underlying data as shown in the patch tutorial, DASCore provides convenience functions to convert data to formats used by other libraries. Here are a few examples:
Pandas
import dascore as dc
patch = dc.get_example_patch()
# Convert to a dataframe
df = patch.io.to_dataframe()
# Convert a dataframe to a patch
patch_from_df = dc.io.dataframe_to_patch(df)Xarray
import dascore as dc
patch = dc.get_example_patch()
# Convert to xarray's DataArray
dar = patch.io.to_xarray()
# Convert a DataArray to a patch
patch_from_dar = dc.io.xarray_to_patch(dar)ObsPy
import dascore as dc
patch = dc.get_example_patch()
# Convert the patch to an ObsPy Stream
stream = patch.io.to_obspy()
# Convert an ObsPy Stream to a patch
patch_from_dar = dc.io.obspy_to_patch(stream)
Note
As explained in the obspy_to_patch docs, the stats dictionary must include a value for at least one non-time dimension. For example, each trace might include a distance key in stats, which DASCore uses to construct the distance coordinate.