Commit 8fca5eeb authored by Anthony Schrapffer's avatar Anthony Schrapffer
Browse files

Update script for merging (error date + some smaller issues).

parent 87a7c8ce
......@@ -556,11 +556,12 @@ def stnnbchecker(C) :
duploc = np.argmin(np.abs(stnnb-dup))
dreg = int(stnnb[duploc]/100000)
dsubreg = int((stnnb[duploc]-dreg*100000)/1000)
regstnnb = stnnb[(stnnb >= dup) & (stnnb < dreg*100000+(dsubreg+1)*1000)]
regstnnb = stnnb[(stnnb >= dup-1000) & (stnnb < dreg*100000+(dsubreg+1)*1000)]
if regstnnb.shape[0] < 1 :
t=dreg*100000+(subreg[i]+1)*1000-1
else :
t= np.max(regstnnb)+1
regnum = np.min(regstnnb)
t= regnum - 1
if not any(stnnb == t) :
stnnb[duploc] = t
C.stations[duploc].Number = t
......@@ -575,12 +576,14 @@ def stnnbchecker(C) :
if np.count_nonzero(stnnb < 0) > 999 :
subreg[:] = subreg[:]-1
mask = np.where(stnnb < 0)
for i in np.nditer(mask) :
regstnnb=stnnb[(stnnb >= reg[i]*100000+subreg[i]*1000) & (stnnb < (reg[i]+1)*100000)]
if len(mask[0])>0:
for i in np.nditer(mask) :
regstnnb = stnnb[(stnnb >= dup-1000) & (stnnb < dreg*100000+(dsubreg+1)*1000)]
if regstnnb.shape[0] < 1 :
t = reg[i]*100000+subreg[i]*1000
else :
t = np.max(regstnnb)+1
regnum = np.min(regstnnb)
t= regnum - 1
if not any(stnnb == t) :
stnnb[i] = t
C.stations[i].Number = stnnb[i]
......
......@@ -46,15 +46,15 @@ C=AS.stnnbchecker(C)
#
print("Number of stations in A = ", A.nbstations," in B = ", B.nbstations, " Merged set has : ", C.nbstations)
print("Time range of input : A=", A.FirstDate(), "-", A.LastDate()," B=", B.FirstDate(), "-", B.LastDate())
nbmonth = int((C.LastDate()-C.FirstDate()).days/365)*12+12
nbmonth = int((C.LastDate().year-C.FirstDate().year)+1)*12
print("Data coverd by merged dataset :", C.FirstDate(), " to ", C.LastDate(), ' or ', nbmonth, ' month.')
AllDates=[]
y=C.FirstDate().year
m=1
d=15
for i in range(nbmonth):
dm=i%12
dy=int((i-dm)/12)+1
dm = i%12
dy = i//12
AllDates.append(datetime.datetime(y+dy, m+dm, d))
#
C.dumpnetcdf(AllDates, OutFile, "Merge of "+FileA+" and "+FileB)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment