rda-python-icoads 1.0.2__tar.gz → 1.0.3__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.
Files changed (18) hide show
  1. {rda_python_icoads-1.0.2 → rda_python_icoads-1.0.3}/PKG-INFO +1 -1
  2. {rda_python_icoads-1.0.2 → rda_python_icoads-1.0.3}/pyproject.toml +1 -1
  3. {rda_python_icoads-1.0.2 → rda_python_icoads-1.0.3}/src/rda_python_icoads/README_R3.0_Subset.html +0 -1
  4. {rda_python_icoads-1.0.2 → rda_python_icoads-1.0.3}/src/rda_python_icoads/imma1_subset.py +20 -39
  5. {rda_python_icoads-1.0.2 → rda_python_icoads-1.0.3}/src/rda_python_icoads.egg-info/PKG-INFO +1 -1
  6. {rda_python_icoads-1.0.2 → rda_python_icoads-1.0.3}/LICENSE +0 -0
  7. {rda_python_icoads-1.0.2 → rda_python_icoads-1.0.3}/MANIFEST.in +0 -0
  8. {rda_python_icoads-1.0.2 → rda_python_icoads-1.0.3}/README.md +0 -0
  9. {rda_python_icoads-1.0.2 → rda_python_icoads-1.0.3}/setup.cfg +0 -0
  10. {rda_python_icoads-1.0.2 → rda_python_icoads-1.0.3}/src/rda_python_icoads/PgIMMA.py +0 -0
  11. {rda_python_icoads-1.0.2 → rda_python_icoads-1.0.3}/src/rda_python_icoads/__init__.py +0 -0
  12. {rda_python_icoads-1.0.2 → rda_python_icoads-1.0.3}/src/rda_python_icoads/rdimma1_csv.f +0 -0
  13. {rda_python_icoads-1.0.2 → rda_python_icoads-1.0.3}/src/rda_python_icoads.egg-info/SOURCES.txt +0 -0
  14. {rda_python_icoads-1.0.2 → rda_python_icoads-1.0.3}/src/rda_python_icoads.egg-info/dependency_links.txt +0 -0
  15. {rda_python_icoads-1.0.2 → rda_python_icoads-1.0.3}/src/rda_python_icoads.egg-info/entry_points.txt +0 -0
  16. {rda_python_icoads-1.0.2 → rda_python_icoads-1.0.3}/src/rda_python_icoads.egg-info/requires.txt +0 -0
  17. {rda_python_icoads-1.0.2 → rda_python_icoads-1.0.3}/src/rda_python_icoads.egg-info/top_level.txt +0 -0
  18. {rda_python_icoads-1.0.2 → rda_python_icoads-1.0.3}/tests/test_icoads.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: rda_python_icoads
3
- Version: 1.0.2
3
+ Version: 1.0.3
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.2"
9
+ version = "1.0.3"
10
10
  authors = [
11
11
  { name="Zaihua Ji", email="zji@ucar.edu" },
12
12
  ]
@@ -94,7 +94,6 @@ column of data provided.
94
94
  <li>Temporal Range: __DATES__</li>
95
95
  <li>Latitude Limits (+<i>&deg;N</i>, -<i>&deg;S</i>): __LATS__</li>
96
96
  <li>Longitude Limits (+<i>&deg;E</i> only): __LONS__</li>
97
- <li>Number of Records: __RECS__</li>
98
97
  </ul>
99
98
 
100
99
  <h3>Your data request details for the required selections</h3>
@@ -130,7 +130,9 @@ def main():
130
130
  PgLOG.cmdlog("{} {}".format(pgcmd, ' '.join(argv)))
131
131
  PgDBI.dssdb_scname()
132
132
  if fidx:
133
- PGFILE = PgDBI.pgget('wfrqst', '*', "findex = {}".format(fidx), PgLOG.LGEREX)
133
+ fcnd = "findex = {}".format(fidx)
134
+ PGFILE = PgDBI.pgget('wfrqst', '*', fcnd, PgLOG.LGEREX)
135
+ if not PGFILE: PgLOG.pglog(fcnd + ": Request File Not in RDADB", PgLOG.LGEREX)
134
136
  if ridx == 0: ridx = PGFILE['rindex']
135
137
  PGRQST = PgSubset.valid_subset_request(ridx, rdir, IDSID, PgLOG.LGWNEX)
136
138
  if not rdir: rdir = PgLOG.join_paths(PgLOG.PGLOG['RQSTHOME'], PGRQST['rqstid'])
@@ -398,11 +400,15 @@ def set_full_attm_info(aname, anames, tcodes, avars, aprecs):
398
400
  def process_subset_request(ridx, rdir, rstr):
399
401
 
400
402
  ptcnt = PGRQST['ptcount']
401
- if ptcnt > 0 and check_request_built(ridx, ptcnt, rstr) != 1: return
403
+ if ptcnt > 0:
404
+ fname = PVALS['rdimma1']
405
+ cnd = "rindex = {} AND wfile = '{}' AND status = 'O'".format(ridx, fname)
406
+ if op.isfile(fname) and PgDBI.pgget("wfrqst", "", cnd): return
402
407
 
403
408
  get_subset_info(rstr)
404
409
 
405
410
  if ptcnt > 0:
411
+ set_var_info()
406
412
  PgFile.change_local_directory(rdir, PgLOG.LOGWRN)
407
413
  build_final_files(ridx, rstr)
408
414
  else:
@@ -418,7 +424,7 @@ def process_subset_request(ridx, rdir, rstr):
418
424
  pgrec['cmd_detail'] = "dates={} {}&tidx={}".format(bdate, edate, tidx)
419
425
  fname = "ICOADS_R3.0_Rqst{}_{}-{}.csv".format(ridx, bdate, edate)
420
426
  PgSubset.add_request_file(ridx, fname, pgrec, PgLOG.LGEREX)
421
-
427
+
422
428
  #
423
429
  # process a validated subset request file
424
430
  #
@@ -447,7 +453,9 @@ def process_subset_file(ridx, fidx, rdir, rstr):
447
453
  if not (tidx and dates):
448
454
  PgLOG.pglog(rstr + ': Miss tidx or date range to build request', PgLOG.LOGWRN)
449
455
 
450
- subset_table_index(PGFILE['wfile'], tidx, dates[0], dates[1])
456
+ recs = subset_table_index(PGFILE['wfile'], tidx, dates[0], dates[1])
457
+
458
+ record = {'note' : "RECS: {}".format(recs)}
451
459
 
452
460
  #
453
461
  # build range dates for subsetting
@@ -465,6 +473,7 @@ def build_table_file(fd, tidx, bdate, edate, atables):
465
473
  tname = "{}_{}".format(aname, tidx)
466
474
  pgrecs = PgDBI.pgmget(tname, "*", qcnd, PgLOG.LGEREX)
467
475
  rcnt = len(pgrecs['iidx']) if pgrecs else 0
476
+ recs = 0
468
477
  for r in range(rcnt):
469
478
  pgrec = {'icoreloc' : PgUtil.onerecord(pgrecs, r)}
470
479
  # quey for all attms
@@ -544,6 +553,9 @@ def build_table_file(fd, tidx, bdate, edate, atables):
544
553
 
545
554
  buf += "\n"
546
555
  fd.write(buf)
556
+ recs += 1
557
+
558
+ return recs
547
559
 
548
560
  #
549
561
  # check if not matching options
@@ -585,40 +597,6 @@ def join_attm_fields(aname, record):
585
597
 
586
598
  return sret
587
599
 
588
- #
589
- # check if all table files are built
590
- #
591
- def check_table_filename(ridx, tidx, edate):
592
-
593
- fname = "Rqst{}-t{:03}.*-{}".format(ridx, tidx, edate.replace('-', ''))
594
- return True if glob.glob(fname) else False
595
-
596
- #
597
- # check if all request data files are built
598
- # return 0 - not yet;
599
- # 1 - all data files are built;
600
- # 2 - all files done including help files
601
- #
602
- def check_request_built(ridx, ptcnt, rstr):
603
-
604
- cnd = "rindex = {} AND status = 'O'".format(ridx)
605
- if ptcnt > 1:
606
- pcnt = PgDBI.pgget('ptrqst', '', cnd)
607
- if pcnt < ptcnt:
608
- PgLOG.pglog('{}: {}/{} Request Partitions not finished yet'.format(rstr, (ptcnt-pcnt), ptcnt), PgLOG.LOGWRN)
609
- return 0
610
- wfcnt = PGRQST['fcount']
611
- fcnt = PgDBI.pgget('wfrqst', '', cnd)
612
- if fcnt < wfcnt:
613
- PgLOG.pglog('{}: {}/{} Request Files not finished yet'.format(rstr, (wfcnt-fcnt), wfcnt), PgLOG.LOGWRN)
614
- return 0
615
- fname = PVALS['rdimma1']
616
- cnd += " AND wfile = '{}'".format(fname)
617
- if op.isfile(fname) and PgDBI.pgget("wfrqst", "", cnd):
618
- PgLOG.pglog('{}: Request built already'.format(rstr), PgLOG.LOGWRN)
619
- return 2
620
- return 1
621
-
622
600
  #
623
601
  # subset data and save in fname
624
602
  #
@@ -634,13 +612,16 @@ def subset_table_index(fname, tidx, bdate, edate):
634
612
  if dstep == 0: dstep = 1
635
613
  PgLOG.pgsystem("echo '{}' > {}".format(PVALS['vhead'], fname), PgLOG.LGWNEX, 1029)
636
614
  fd = open(fname, 'a')
615
+ recs = 0
637
616
  while bdate <= edate:
638
617
  pdate = PgUtil.adddate(bdate, 0, 0, dstep)
639
618
  if pdate > edate: pdate = edate
640
- build_table_file(fd, tidx, bdate, pdate, atables)
619
+ recs += build_table_file(fd, tidx, bdate, pdate, atables)
641
620
  bdate = PgUtil.adddate(pdate, 0, 0, 1)
642
621
 
643
622
  fd.close()
623
+
624
+ return recs
644
625
 
645
626
  #
646
627
  # build the final subset files
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: rda_python_icoads
3
- Version: 1.0.2
3
+ Version: 1.0.3
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