dartobsgen.trim_obs_seq#
- dartobsgen.trim_obs_seq(input_file, polygon, output_file=None)[source]#
Trim observations in a DART obs_seq file to those inside a polygon.
Uses
pydartdiags.ObsSequenceto read and write the file, so this function is data-source agnostic — it works on any obs_seq file regardless of how it was produced.A fast bounding-box pre-filter is applied first; only points surviving the bbox check are tested with the exact
shapely.contains_xycall.- Parameters:
input_file (str) – Path to the input DART obs_seq file.
polygon (shapely.geometry.Polygon) – Boundary polygon in (longitude, latitude) coordinates (degrees). Build one with
polygon_from_vertices(),polygon_from_netcdf_vertices(), orpolygon_from_netcdf_mask().output_file (str or None) – Destination path for the trimmed file.
None(default) overwritesinput_filein place.
- Returns:
True if at least one observation survived the trim and the output file was written; False if no observations fell inside the polygon.
- Return type: