rda-python-icoads 1.0.13__tar.gz → 1.0.17__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of rda-python-icoads might be problematic. Click here for more details.

Files changed (37) hide show
  1. {rda_python_icoads-1.0.13/src/rda_python_icoads.egg-info → rda_python_icoads-1.0.17}/PKG-INFO +1 -1
  2. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/pyproject.toml +1 -1
  3. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads/PgIMMA.py +23 -17
  4. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads/cleanicoads.py +4 -3
  5. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads/fillicoads.py +29 -20
  6. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads/fillitable.py +2 -1
  7. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads/imma1_subset.py +2 -2
  8. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17/src/rda_python_icoads.egg-info}/PKG-INFO +1 -1
  9. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/LICENSE +0 -0
  10. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/MANIFEST.in +0 -0
  11. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/README.md +0 -0
  12. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/setup.cfg +0 -0
  13. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads/R3.0-stat_doc.pdf +0 -0
  14. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads/README_R3.0_Subset.html +0 -0
  15. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads/__init__.py +0 -0
  16. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads/checkicoads.py +0 -0
  17. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads/countattm.py +0 -0
  18. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads/countattmvar.py +0 -0
  19. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads/counticoads.py +0 -0
  20. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads/countsst.py +0 -0
  21. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads/fillinventory.py +0 -0
  22. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads/fillmonth.py +0 -0
  23. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads/fixiidx.py +0 -0
  24. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads/maxsst.py +0 -0
  25. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads/msg +0 -0
  26. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads/msg3.0_subset_readme.txt +0 -0
  27. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads/msg3_subset.py +0 -0
  28. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads/msg_download.py +0 -0
  29. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads/msgsubset.f +0 -0
  30. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads/rdimma1_csv.f +0 -0
  31. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads/writeicoads.py +0 -0
  32. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads.egg-info/SOURCES.txt +0 -0
  33. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads.egg-info/dependency_links.txt +0 -0
  34. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads.egg-info/entry_points.txt +0 -0
  35. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads.egg-info/requires.txt +0 -0
  36. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/src/rda_python_icoads.egg-info/top_level.txt +0 -0
  37. {rda_python_icoads-1.0.13 → rda_python_icoads-1.0.17}/tests/test_icoads.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rda_python_icoads
3
- Version: 1.0.13
3
+ Version: 1.0.17
4
4
  Summary: RDA python package to manage RDA ICOADS datasets
5
5
  Author-email: Zaihua Ji <zji@ucar.edu>
6
6
  Project-URL: Homepage, https://github.com/NCAR/rda-python-icoads
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
 
7
7
  [project]
8
8
  name = "rda_python_icoads"
9
- version = "1.0.13"
9
+ version = "1.0.17"
10
10
  authors = [
11
11
  { name="Zaihua Ji", email="zji@ucar.edu" },
12
12
  ]
@@ -343,8 +343,8 @@ MUNIQUE = {
343
343
  'iivad' : ['arci', 'cdi']
344
344
  }
345
345
 
346
- IVADSC = 'ivaddb1'
347
- CNTLSC = 'cntldb1'
346
+ IVADSC = 'ivaddb'
347
+ CNTLSC = 'cntldb'
348
348
 
349
349
  MULTI_NAMES = []
350
350
  ATTI2NAME = {}
@@ -454,7 +454,7 @@ def get_imma_records(cdate, line, records):
454
454
  aname = ATTI2NAME[line[offset:offset+2]]
455
455
  imma = IMMAS[aname]
456
456
  pgrec = get_one_attm(imma[3], offset, line)
457
- #48 if aname == 'iivad': pgrec['cdi'] = PgUtil.adddate('2014-01-01', 0, 0, I36(pgrec['cdi']), 'YYYMMDD')
457
+ #48 if aname == 'iivad': pgrec['cdi'] = PgUtil.adddate('2014-01-01', 0, 0, I36(pgrec['cdi']), 'YYYYMMDD')
458
458
  if aname not in records: records[aname] = initialize_attm_records(imma[3])
459
459
  if CURIUID:
460
460
  append_one_attm(cdate, imma[0], imma[3], pgrec, records[aname])
@@ -1115,27 +1115,33 @@ def get_imma_date(line):
1115
1115
  def get_itidx_date(uid):
1116
1116
 
1117
1117
  global CURIUID, CURIIDX, CURTIDX
1118
+ if CURRN3 < 0: PgLOG.pglog(f"{uid}: Provide a RN3 (>= 0) to proceed", PgLOG.LGEREX)
1118
1119
  uidx = uid[0:2].lower()
1119
1120
  suid = uid[2:6]
1120
1121
  table = f"{CNTLSC}.itidx_{uidx}"
1121
- cond = f"suid = '{suid}' AND rn3 = {CURRN3}"
1122
- pgrec = PgDBI.pgget(table, "*", cond, PgLOG.LGEREX)
1123
- if not pgrec:
1124
- msg = "{}-{}: suid-rn3 not in {}".format(suid, CURRN3, table)
1125
- if CURRN3 < 0:
1126
- PgLOG.pglog(msg + "\nProvide a RN3 (>= 0) to proceed", PgLOG.LGEREX)
1127
- else:
1128
- return PgLOG.pglog(msg + ", SKIP it", PgLOG.WARNLG)
1129
-
1122
+ cond = f"suid = '{suid}'"
1123
+ pgrecs = PgDBI.pgmget(table, "*", cond, PgLOG.LGEREX)
1124
+ ucnt = len(pgrecs['iidx']) if pgrecs else 0
1125
+ if ucnt == 0: return PgLOG.pglog(f"{uid}: not in table {table}, SKIP it", PgLOG.WARNLG)
1126
+
1127
+ uidx = -1
1128
+ for i in range(ucnt):
1129
+ if pgrecs['rn3'][i] == CURRN3:
1130
+ uidx = i
1131
+ break
1132
+ if uidx == -1: return PgLOG.pglog(f"{uid}: not in table {table} for rn3({CURRN3}), SKIP it", PgLOG.WARNLG)
1133
+
1134
+ iidx = pgrecs['iidx'][uidx]
1135
+ tidx = pgrecs['tidx'][uidx]
1130
1136
  if CHKEXIST: # check
1131
- table = f"{IVADSC}.{ATTMNAME}_{pgrec['tidx']}"
1132
- cnd = f"iidx = {pgrec['iidx']}"
1137
+ table = f"{IVADSC}.{ATTMNAME}_{tidx}"
1138
+ cnd = f"iidx = {iidx}"
1133
1139
  if PgDBI.pgget(table, "", cnd): return None
1134
1140
 
1135
1141
  CURIUID = uid
1136
- CURIIDX = pgrec['iidx']
1137
- CURTIDX = pgrec['tidx']
1138
- return pgrec['date']
1142
+ CURIIDX = iidx
1143
+ CURTIDX = tidx
1144
+ return pgrecs['date'][uidx]
1139
1145
 
1140
1146
  #
1141
1147
  # get record date for given year, month and day
@@ -107,9 +107,10 @@ def clean_imma_data():
107
107
  else:
108
108
  clean_imma_data_for_tidx(tidx, cnd)
109
109
 
110
- cnt = PgDBI.pgdel(table, PVALS['dcnd'], PgLOG.LGEREX)
111
- s = 's' if cnt > 1 else ''
112
- PgLOG.pglog("{}: {} record{} deleted for {}".format(table, cnt, s, PVALS['dcnd']), PgLOG.LOGWRN)
110
+ if not PVALS['aname']:
111
+ cnt = PgDBI.pgdel(table, PVALS['dcnd'], PgLOG.LGEREX)
112
+ s = 's' if cnt > 1 else ''
113
+ PgLOG.pglog("{}: {} record{} deleted for {}".format(table, cnt, s, PVALS['dcnd']), PgLOG.LOGWRN)
113
114
 
114
115
  #
115
116
  # clean up imma data for table index
@@ -19,12 +19,15 @@ import re
19
19
  from os import path as op
20
20
  from rda_python_common import PgLOG
21
21
  from rda_python_common import PgDBI
22
+ from rda_python_common import PgUtil
22
23
  from . import PgIMMA
23
24
 
24
25
  PVALS = {
25
26
  'uatti' : '',
26
27
  'names' : None,
27
- 'files' : []
28
+ 'files' : [],
29
+ 'dates' : [],
30
+ 'dtlen' : 0
28
31
  }
29
32
 
30
33
  #
@@ -38,25 +41,29 @@ def main():
38
41
 
39
42
  option = None
40
43
  for arg in argv:
41
- if arg == "-b":
42
- PgLOG.PGLOG['BCKGRND'] = 1
43
- elif arg == "-a":
44
- PVALS['uatti'] = "98"
45
- elif arg == "-u":
46
- leaduid = 1
47
- elif arg == "-e":
48
- chkexist = 1
49
- elif arg == "-f":
50
- option = 'f'
51
- elif arg == "-r":
52
- option = 'r'
53
- elif arg == "-i":
54
- addinventory = 1
55
- elif re.match(r'^-', arg):
56
- PgLOG.pglog(arg + ": Invalid Option", PgLOG.LGWNEX)
44
+ if re.match(r'-\w', arg):
45
+ option = None
46
+ if arg[1] == "b":
47
+ PgLOG.PGLOG['BCKGRND'] = 1
48
+ elif arg[1] == "a":
49
+ PVALS['uatti'] = "98"
50
+ elif arg[1] == "u":
51
+ leaduid = 1
52
+ elif arg[1] == "e":
53
+ chkexist = 1
54
+ elif arg[1] == "i":
55
+ addinventory = 1
56
+ elif arg[1] in "fpr":
57
+ option = arg[1]
58
+ else:
59
+ PgLOG.pglog(arg + ": Invalid Option", PgLOG.LGWNEX)
57
60
  elif option == 'f':
58
61
  get_imma_filelist(arg)
59
62
  option = None
63
+ elif option == 'p':
64
+ PVALS['dates'].append(PgUtil.format_date(arg))
65
+ PVALS['dtlen'] += 1
66
+ if PVALS['dtlen'] == 2: option = None
60
67
  elif option == 'r':
61
68
  rn3 = int(arg)
62
69
  option = None
@@ -64,11 +71,12 @@ def main():
64
71
  PVALS['files'].append(arg)
65
72
 
66
73
  if not PVALS['files']:
67
- print("Usage: fillicoads [-a] [-e] [-f InputFile] [-i] [-r RN3] [-u] FileList")
74
+ print("Usage: fillicoads [-a] [-e] [-f InputFile] [-i] [-p BDate [EDate]] [-r RN3] [-u] FileList")
68
75
  print(" At least one file name needs to fill icoads data into Postgres Server")
69
76
  print(" Option -a: add all attms, including multi-line ones, such as IVAD and REANQC")
70
77
  print(" Option -f: provide a filename holding a list of IMMA1 files")
71
78
  print(" Option -i: add daily counting records into inventory table")
79
+ print(" Option -p: provide a period for filling data")
72
80
  print(" Option -r: the Third digit of IMMA release number")
73
81
  print(" Option -u: standalone attachment records with leading 6-character UID")
74
82
  print(" Option -e: check existing record before adding attm")
@@ -121,10 +129,10 @@ def process_imma_file(fname, addinventory):
121
129
 
122
130
  # get the first valid date and do initialization
123
131
  line = IMMA.readline()
132
+ PgIMMA.identify_attm_name(line) # check and record standalone attm name
124
133
  while line:
125
- PgIMMA.identify_attm_name(line) # check and record standalone attm name
126
134
  idate = cdate = PgIMMA.get_imma_date(line)
127
- if cdate:
135
+ if cdate and (PVALS['dtlen'] == 0 or PgUtil.diffdate(cdate, PVALS['dates'][0]) >= 0):
128
136
  PgIMMA.init_indices_for_date(cdate, iname)
129
137
  records = PgIMMA.get_imma_records(cdate, line, records)
130
138
  break
@@ -142,6 +150,7 @@ def process_imma_file(fname, addinventory):
142
150
  for i in range(PgIMMA.TABLECOUNT): acounts[i] += acnts[i]
143
151
  records = {}
144
152
  cdate = idate
153
+ if PVALS['dtlen'] == 2 and PgUtil.diffdate(cdate, PVALS['dates'][1]) > 0: break
145
154
  PgIMMA.init_indices_for_date(cdate, iname)
146
155
  records = PgIMMA.get_imma_records(idate, line, records)
147
156
  line = IMMA.readline()
@@ -143,6 +143,7 @@ def add_field_records():
143
143
  acnt += 1
144
144
  elif stat == 2:
145
145
  ucnt += 1
146
+ line = IVAR.readline()
146
147
 
147
148
  IVAR.close()
148
149
  PgLOG.pglog("{}/{} of {} values added/updated into table {}".format(acnt, ucnt, vcnt, vtable), PgLOG.LOGWRN)
@@ -152,7 +153,7 @@ def add_field_records():
152
153
  #
153
154
  def add_field_value(var, vtable, key, desc):
154
155
 
155
- cnd = "{} = {}".foramt(var, key)
156
+ cnd = "{} = {}".format(var, key)
156
157
 
157
158
  pgrec = PgDBI.pgget(vtable, "*", cnd)
158
159
 
@@ -607,9 +607,9 @@ def join_attm_fields(aname, record):
607
607
  def subset_table_index(fname, tidx, bdate, edate):
608
608
 
609
609
  atables = {}
610
- PgDBI.set_scname(dbname = 'ivaddb', scname = PgIMMA.IVADSC, lnname = 'ivaddb', dbhost = PgLOG.PGLOG['PMISCHOST'])
610
+ PgDBI.set_scname(dbname = 'ivaddb', scname = 'ivaddb', lnname = 'ivaddb', dbhost = PgLOG.PGLOG['PMISCHOST'])
611
611
 
612
- tname = f"{PgIMMA.CTNLSC}.iattm"
612
+ tname = "cntldb.iattm"
613
613
  for aname in PVALS['anames']:
614
614
  cnd = f"tidx = {tidx} AND attm = '{aname}'"
615
615
  atables[aname] = PgDBI.pgget(tname, "", cnd, PgLOG.LGEREX)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rda_python_icoads
3
- Version: 1.0.13
3
+ Version: 1.0.17
4
4
  Summary: RDA python package to manage RDA ICOADS datasets
5
5
  Author-email: Zaihua Ji <zji@ucar.edu>
6
6
  Project-URL: Homepage, https://github.com/NCAR/rda-python-icoads