aisdb.proc_util module
- aisdb.proc_util.getfiledate(filename)[source]
attempt to parse the first valid epoch timestamp from .nm4 data file. timestamp will be returned as
datetime.date
if successful, otherwise will return False if no date could be found- Parameters:
filename (string) – raw AIS data file in .nm4 format
- aisdb.proc_util.glob_files(dirpath, ext='.txt', keyorder=<function <lambda>>)[source]
walk a directory to glob txt files. can be used with ZoneGeomFromTxt()
- zones_dir: string
directory to walk
- keyorder:
anonymous function for custom sort ordering
example keyorder:
# numeric sort on zone names with strsplit on 'Z' char keyorder=lambda key: int(key.rsplit(os.path.sep, 1)[1].split('.')[0].split('Z')[1])
- Returns:
.txt shapefile paths
- aisdb.proc_util.tracks_csv(tracks, skipcols: list = ['label', 'in_zone'])[source]
Yields row tuples when given a track generator. See write_csv() for more info
- aisdb.proc_util.write_csv(tracks, fpath: BytesIO | str | SpooledTemporaryFile, skipcols: list = ['label', 'in_zone'])[source]
write track vector dictionaries as CSV file
- Parameters:
tracks (iter) – track generator such as returned by
aisdb.track_gen.TrackGen()
fpath (string) – output CSV filepath (string) or io.BytesIO buffer
skipcols (list) – columns to be omitted from results