Skip to content

Commit 2626991

Browse files
Merge branch 'main' into examples
2 parents 065f6b7 + 152934b commit 2626991

2 files changed

Lines changed: 12 additions & 14 deletions

File tree

cdippy/nchashes.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44

55
class NcHashes:
6-
"""Methods for working with the online list of historic nc file hashes."""
6+
"""
7+
A class that checks for changes to datasets since by reading the online list of historic netCDF file hashes.
8+
"""
79

810
hashes_url = "http://cdip.ucsd.edu/data_access/metadata/wavecdf_by_datemod.txt"
911
new_hashes = {}
@@ -21,17 +23,14 @@ def load_hash_table(self):
2123
continue
2224
self.new_hashes[fields[0]] = fields[6]
2325

24-
def get_last_deployment(self, stn: str) -> str:
25-
"""Returns the last deployment string, e.g. 'd03'."""
26-
last_deployment = "d00"
27-
for name in self.new_hashes:
28-
if name[0:5] == stn and name[5:7] == "_d" and last_deployment < name[6:9]:
29-
last_deployment = name[6:9]
30-
return last_deployment
31-
3226
def compare_hash_tables(self) -> list:
33-
"""Return a list of nc files that have changed or are new."""
34-
old_hashes = self.get_old_hashes()
27+
"""
28+
Compare the current in-memory list of files, loaded by `load_hash_table` to the list saved in HASH.pkl and return a list of stations that are new or have changed.
29+
30+
Returns:
31+
changed ([str]): A list of nc files that have changed or are since HASH.pkl was last saved.
32+
"""
33+
old_hashes = self._get_old_hashes()
3534
changed = []
3635
if old_hashes:
3736
if len(self.new_hashes) == 0:
@@ -46,5 +45,5 @@ def compare_hash_tables(self) -> list:
4645
def save_new_hashes(self):
4746
cdip_utils.pkl_dump(self.new_hashes, self.hash_pkl)
4847

49-
def get_old_hashes(self):
48+
def _get_old_hashes(self):
5049
return cdip_utils.pkl_load(self.hash_pkl)

cdippy/ndbc.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,4 @@ def get_wmo_id(
4545
ids = cdip_utils.pkl_load(pkl_fl)
4646
if stn in ids:
4747
return ids[stn]
48-
else:
49-
return None
48+
return None

0 commit comments

Comments
 (0)