def run_example(): """ This is the data for the example. Note that you want the data to be at least 4 days longer than the desired output """ start = dtm.datetime(2009, 2, 18) end = dtm.datetime(2010, 11, 24) out_st = dtm.datetime(2009, 3, 12) out_end = dtm.datetime(2010, 11, 2) sf_path = "../9415020_gageheight.csv" ts = read_ts(sf_path, start, end) print("separating reys...") separate_species(ts, "rey", out_st, out_end, do_plot=True) print("all done")
def main(): parser = create_arg_parser() args = parser.parse_args() if args.stime: sdate = dtm.datetime(*list(map(int, re.split( '[^\d]', args.stime)))) # convert start time string input to datetime else: sdate = None if args.etime: edate = dtm.datetime(*list(map(int, re.split( '[^\d]', args.etime)))) # convert start time string input to datetime else: edate = None data_file = args.infile station_name = args.label outprefix = args.outprefix if not outprefix: outprefix = station_name.replace(" ", "_") do_plot = args.plot ts = read_ts(data_file, None, None) astart = max(ts.start, sdate - days(5)) if sdate else ts.start aend = min(ts.end, edate + days(5)) if edate else ts.end ts_sub, ts_diurnal, ts_semi, ts_noise = separate_species( ts.window(astart, aend)) comps = [(ts_noise, "noise"), (ts_semi, "semi_over"), (ts_diurnal, "diurnal"), (ts_sub, "subtidal")] for comp in comps: ts_output = comp[0].window(sdate, edate) output_file = outprefix + "_" + comp[1] + ".th" write_th(output_file, ts_output) if do_plot: plot_result(ts.window(sdate, edate), ts_semi.window(sdate, edate), ts_diurnal.window(sdate, edate), ts_sub.window(sdate, edate), station_name)