changeset 178:c42a5f7c97c5

renamed to by_interval.py
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Fri, 24 Nov 2023 20:40:09 +0000
parents a5d54736a77f
children 16d603447fbc
files bin/by_year.py
diffstat 1 files changed, 0 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/bin/by_year.py	Fri Nov 24 20:39:08 2023 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-#!/usr/bin/python3
-'''Split stamped data by year
-Usage: origin-year output-dir by_year.py year-file sorted-ks-file.tsv [field]
-If field is given, ks-file is tsv and stamp is in that field,
-which, as for cut, is 1-origin'''
-
-import sys, os, os.path
-
-if len(sys.argv)>5:
-  (origin, outdir, year_file, in_file, field) = sys.argv[1:]
-  field=int(field)-1
-else:
-  (origin, outdir, year_file, in_file) = sys.argv[1:]
-  field=3
-
-if not os.access(outdir,os.F_OK):
-  os.mkdir(outdir)
-
-origin = int(origin)
-current = origin
-is_first = True
-with open(year_file,'r') as years, open(in_file,'r') as stamped:
-  y = years.readline()
-  l = stamped.readline()
-  while y:
-    y = float(y)
-    if is_first:
-      ysuf = 'prev'
-    else:
-      ysuf = str(current-1)
-    with open(os.path.join(outdir,'ks_%s.tsv'%ysuf),'w') as y_file:
-      while l:
-        if float(l.split('\t')[field]) < y:
-          y_file.write(l)
-        else:
-          break
-        l = stamped.readline()
-    y = years.readline()
-    current += 1
-    is_first = False
-  else:
-    with open(os.path.join(outdir,'ks_post.tsv'),'w') as y_file:
-      while l:
-        y_file.write(l)
-        l = stamped.readline()