12.9.1-11 baseline
Former-commit-id:6eb6b0909b
[formerly6eb6b0909b
[formerly 046d9078b7aa87ff8df98142556713fe38d95c63]] Former-commit-id:fc405efab7
Former-commit-id:a14374fcd4
This commit is contained in:
parent
5bb474d33c
commit
f401755cde
5 changed files with 114 additions and 74 deletions
|
@ -415,10 +415,6 @@ public class FFMPResource extends
|
|||
FFFGDataMgr.getUpdatedInstance();
|
||||
PluginDataObject[] pdos = (PluginDataObject[]) object;
|
||||
FFMPRecord ffmpRec = (FFMPRecord) pdos[pdos.length - 1];
|
||||
if (getTimeOrderedKeys().contains(
|
||||
ffmpRec.getDataTime().getRefTime())) {
|
||||
return;
|
||||
}
|
||||
// an update clears everything
|
||||
clear();
|
||||
// only care about the most recent one
|
||||
|
|
|
@ -128,33 +128,45 @@ public final class GagePPWrite {
|
|||
* new six hour precip value
|
||||
*/
|
||||
public static void gage_pp_write_rec(String pe, String id, String ts,
|
||||
Date obsdate, GagePPOptions options, short revision[],
|
||||
Date obsdate, GagePPOptions options, short revision,
|
||||
short revision_6hour[], double new_hourly_value, double pp_value) {
|
||||
|
||||
int is_pc = 0;
|
||||
int six = 0;
|
||||
Date dto = obsdate;
|
||||
Date dto = new Date(obsdate.getTime());
|
||||
|
||||
Calendar dt = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
|
||||
dt.setTime(dto);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
String obstime = sdf.format(dto);
|
||||
GagePPOptions opts = options;
|
||||
int hr = dt.get(Calendar.HOUR_OF_DAY);
|
||||
int min = dt.get(Calendar.MINUTE);
|
||||
|
||||
//
|
||||
if (hr==0) {
|
||||
hr=24;
|
||||
dt.add(Calendar.DAY_OF_MONTH, -1);
|
||||
dto=dt.getTime();
|
||||
}
|
||||
|
||||
String obstime = sdf.format(dto);
|
||||
|
||||
char sixhroffset = get_offset_code(min);
|
||||
char sixhrqc = 'M';
|
||||
char minoff = sixhroffset;
|
||||
char qcc = sixhrqc;
|
||||
hourly_rec = null;
|
||||
|
||||
//
|
||||
String where = "WHERE lid='" + id + "' AND ts='" + ts
|
||||
+ "' AND obsdate ='" + obstime + "'";
|
||||
|
||||
if (hr >= 0 && hr <= 6) {
|
||||
six = 0;
|
||||
} else if (hr >= 7 && hr <= 12) {
|
||||
} else if (hr > 6 && hr <= 12) {
|
||||
six = 1;
|
||||
} else if (hr >= 13 && hr <= 18) {
|
||||
} else if (hr > 12 && hr <= 18) {
|
||||
six = 2;
|
||||
} else {
|
||||
six = 3;
|
||||
|
@ -178,8 +190,8 @@ public final class GagePPWrite {
|
|||
}
|
||||
|
||||
if (hourly_rec == null) {
|
||||
minute_offset[hr - 1] = minoff;
|
||||
hourly_qc[hr - 1] = qcc;
|
||||
setMinOffset(minute_offset, hr, minoff);
|
||||
setHourlyQC(hourly_qc, hr, qcc);
|
||||
sixhr_offset[six] = sixhroffset;
|
||||
sixhr_qc[six] = sixhrqc;
|
||||
|
||||
|
@ -240,25 +252,29 @@ public final class GagePPWrite {
|
|||
System.out.println("Hourly Rec is null.");
|
||||
}
|
||||
old_offset = hourly_rec.getMinuteOffset().toCharArray();
|
||||
prev_offset = old_offset[hr - 1];
|
||||
int slot = getOffset(old_offset, hr);
|
||||
slot=hr-1;
|
||||
prev_offset = old_offset[slot];
|
||||
old_qc = hourly_rec.getHourlyQc().toCharArray();
|
||||
prev_qc = old_qc[hr - 1];
|
||||
int qcslot = getOffset(old_qc, hr);
|
||||
qcslot=hr-1;
|
||||
prev_qc = old_qc[qcslot];
|
||||
|
||||
int use_value = 1;
|
||||
|
||||
if (get_hour_slot_value(hourly_rec, hr) != null) {
|
||||
old_hr_value = get_hour_slot_value(hourly_rec, hr);
|
||||
use_value = use_precip_value(new_hourly_value, old_hr_value,
|
||||
qcc, prev_qc, minute_offset[hr - 1], prev_offset,
|
||||
opts.shef_duplicate.name(), revision[hr - 1]);
|
||||
qcc, prev_qc, minute_offset[slot], prev_offset,
|
||||
opts.shef_duplicate.name(), revision);
|
||||
}
|
||||
|
||||
if (use_value == 1) {
|
||||
hr_value = new_hourly_value;
|
||||
offset = old_offset;
|
||||
offset[hr - 1] = minoff;
|
||||
offset[slot] = minoff;
|
||||
qc = old_qc;
|
||||
qc[hr - 1] = qcc;
|
||||
qc[qcslot] = qcc;
|
||||
} else {
|
||||
hr_value = old_hr_value;
|
||||
offset = old_offset;
|
||||
|
@ -482,12 +498,12 @@ public final class GagePPWrite {
|
|||
Arrays.fill(sixhr_qc, '-');
|
||||
Arrays.fill(sixhr_offset, '-');
|
||||
|
||||
if (hour_slot == 0) {
|
||||
hour_slot = 24;
|
||||
dt.add(Calendar.HOUR_OF_DAY, -1);
|
||||
}
|
||||
minute_offset[hour_slot - 1] = zero_offset_code;
|
||||
hourly_qc[hour_slot - 1] = manual_qc_code;
|
||||
// if (hour_slot == 0) {
|
||||
// hour_slot = 24;
|
||||
// dt.add(Calendar.HOUR_OF_DAY, -1);
|
||||
// }
|
||||
minute_offset[hour_slot] = zero_offset_code;
|
||||
hourly_qc[hour_slot] = manual_qc_code;
|
||||
set_hour_slot_value(hourly_rec, hour_slot, new_hourly_value);
|
||||
return hour_slot;
|
||||
}
|
||||
|
@ -507,6 +523,46 @@ public final class GagePPWrite {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param qc
|
||||
* @param hour
|
||||
* @param value
|
||||
*/
|
||||
public static final void setMinOffset(char [] minOffset, int hour, char value) {
|
||||
if(hour == 0) {
|
||||
hour = 23;
|
||||
} else {
|
||||
hour--;
|
||||
}
|
||||
minOffset[hour] = value;
|
||||
}
|
||||
|
||||
// get the correct offset slot in array based on hour
|
||||
public static final int getOffset(char[] minOffset, int hour){
|
||||
int slot = 0;
|
||||
if(hour == 0){
|
||||
slot = 23;
|
||||
}else {
|
||||
slot = hour--;
|
||||
}
|
||||
return slot;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param qc
|
||||
* @param hour
|
||||
* @param value
|
||||
*/
|
||||
public static final void setHourlyQC(char [] qc, int hour, char value) {
|
||||
if(hour == 0) {
|
||||
hour = 23;
|
||||
} else {
|
||||
hour--;
|
||||
}
|
||||
qc[hour] = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the offset code based on minute of the hour.
|
||||
*
|
||||
|
@ -808,122 +864,98 @@ public final class GagePPWrite {
|
|||
*/
|
||||
switch (hour) {
|
||||
case 1:
|
||||
|
||||
precip_value = pHourlyPP.getHour1();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
||||
precip_value = pHourlyPP.getHour2();
|
||||
break;
|
||||
|
||||
case 3:
|
||||
|
||||
precip_value = pHourlyPP.getHour3();
|
||||
break;
|
||||
|
||||
case 4:
|
||||
|
||||
precip_value = pHourlyPP.getHour4();
|
||||
break;
|
||||
|
||||
case 5:
|
||||
|
||||
precip_value = pHourlyPP.getHour5();
|
||||
break;
|
||||
|
||||
case 6:
|
||||
|
||||
precip_value = pHourlyPP.getHour6();
|
||||
break;
|
||||
|
||||
case 7:
|
||||
|
||||
precip_value = pHourlyPP.getHour7();
|
||||
break;
|
||||
|
||||
case 8:
|
||||
|
||||
precip_value = pHourlyPP.getHour8();
|
||||
break;
|
||||
|
||||
case 9:
|
||||
|
||||
precip_value = pHourlyPP.getHour9();
|
||||
break;
|
||||
|
||||
case 10:
|
||||
|
||||
precip_value = pHourlyPP.getHour10();
|
||||
break;
|
||||
|
||||
case 11:
|
||||
|
||||
precip_value = pHourlyPP.getHour11();
|
||||
break;
|
||||
|
||||
case 12:
|
||||
|
||||
precip_value = pHourlyPP.getHour12();
|
||||
break;
|
||||
|
||||
case 13:
|
||||
|
||||
precip_value = pHourlyPP.getHour13();
|
||||
break;
|
||||
|
||||
case 14:
|
||||
|
||||
precip_value = pHourlyPP.getHour14();
|
||||
break;
|
||||
|
||||
case 15:
|
||||
|
||||
precip_value = pHourlyPP.getHour15();
|
||||
break;
|
||||
|
||||
case 16:
|
||||
|
||||
precip_value = pHourlyPP.getHour16();
|
||||
break;
|
||||
|
||||
case 17:
|
||||
|
||||
precip_value = pHourlyPP.getHour17();
|
||||
break;
|
||||
|
||||
case 18:
|
||||
|
||||
precip_value = pHourlyPP.getHour18();
|
||||
break;
|
||||
|
||||
case 19:
|
||||
|
||||
precip_value = pHourlyPP.getHour19();
|
||||
break;
|
||||
|
||||
case 20:
|
||||
|
||||
precip_value = pHourlyPP.getHour20();
|
||||
break;
|
||||
|
||||
case 21:
|
||||
|
||||
precip_value = pHourlyPP.getHour21();
|
||||
break;
|
||||
|
||||
case 22:
|
||||
|
||||
precip_value = pHourlyPP.getHour22();
|
||||
break;
|
||||
|
||||
case 23:
|
||||
|
||||
precip_value = pHourlyPP.getHour23();
|
||||
break;
|
||||
|
||||
case 0:
|
||||
|
||||
case 24:
|
||||
precip_value = pHourlyPP.getHour24();
|
||||
break;
|
||||
|
||||
|
@ -1063,7 +1095,7 @@ public final class GagePPWrite {
|
|||
pHourly.setHour23(precip_value);
|
||||
break;
|
||||
|
||||
case 0:
|
||||
case 24:
|
||||
precip_value = new Short((short) val);
|
||||
pHourly.setHour24(precip_value);
|
||||
break;
|
||||
|
|
|
@ -115,7 +115,7 @@ public class RegenHrFlds {
|
|||
|
||||
double new_hourly_value;
|
||||
|
||||
short[] revision = new short[24];
|
||||
short revision;
|
||||
|
||||
short[] revision_6hour = new short[4];
|
||||
|
||||
|
@ -238,15 +238,12 @@ public class RegenHrFlds {
|
|||
hour_slot = GagePPWrite.gage_pp_init(datetime,
|
||||
gData.id, gData.ts, new_hourly_value, obsdate,
|
||||
zero_offset_code, manual_qc_code);
|
||||
for (j = 0; j < NUM_HOURLY_SLOTS; ++j) {
|
||||
revision[j] = 0;
|
||||
}
|
||||
|
||||
for (j = 0; j < NUM_6HOURLY_SLOTS; ++j) {
|
||||
revision_6hour[j] = 0;
|
||||
}
|
||||
|
||||
revision[hour_slot - 1] = 1;
|
||||
revision = 1;
|
||||
|
||||
try {
|
||||
GagePPWrite.gage_pp_write_rec("PP", gData.id,
|
||||
|
@ -282,6 +279,7 @@ public class RegenHrFlds {
|
|||
Calendar cl = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
|
||||
cl.setTime(datetime);
|
||||
int hh = cl.get(Calendar.HOUR_OF_DAY);
|
||||
hh = hour_slot;
|
||||
String hour = "" + hh;
|
||||
if (hh < 10) {
|
||||
hour = "0" + hh;
|
||||
|
@ -357,9 +355,22 @@ public class RegenHrFlds {
|
|||
private void update_rawPP(Date datetime, String id, String ts,
|
||||
char manual_qc_code, int pp_1hr_dur, double pp_value) {
|
||||
|
||||
Date dto = new Date(datetime.getTime());
|
||||
Calendar dt = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
|
||||
dt.setTime(dto);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
int hr = dt.get(Calendar.HOUR_OF_DAY);
|
||||
|
||||
//
|
||||
if (hr==0) {
|
||||
hr=24;
|
||||
dt.add(Calendar.DAY_OF_MONTH, -1);
|
||||
}
|
||||
|
||||
String where = "WHERE lid='" + id + "' AND pe='PP'" + " AND dur="
|
||||
+ pp_1hr_dur + " AND ts='" + ts + "' AND extremum='Z'"
|
||||
+ " AND obstime='" + sdf.format(datetime) + "'";
|
||||
+ " AND obstime='" + sdf.format(dt.getTime()) + "'";
|
||||
List<Rawpp> rawpp_rec = MPEDataManager.getInstance().getRawPP(where);
|
||||
|
||||
if (rawpp_rec.isEmpty()) {
|
||||
|
@ -373,9 +384,9 @@ public class RegenHrFlds {
|
|||
+ ts
|
||||
+ "','Z'"
|
||||
+ ",'"
|
||||
+ sdf.format(datetime)
|
||||
+ sdf.format(dt.getTime())
|
||||
+ "','"
|
||||
+ sdf.format(datetime)
|
||||
+ sdf.format(dt.getTime())
|
||||
+ "','"
|
||||
+ manual_qc_code
|
||||
+ "',"
|
||||
|
@ -391,11 +402,11 @@ public class RegenHrFlds {
|
|||
where = "set value=" + pp_value + ",shef_Qual_Code='"
|
||||
+ manual_qc_code + "',revision=1" + ",quality_Code="
|
||||
+ ShefConstants.QC_MANUAL_PASSED + ",producttime='"
|
||||
+ sdf.format(datetime) + "',postingtime='"
|
||||
+ sdf.format(datetime) + "' WHERE lid='" + id
|
||||
+ sdf.format(dt.getTime()) + "',postingtime='"
|
||||
+ sdf.format(dt.getTime()) + "' WHERE lid='" + id
|
||||
+ "' AND pe='PP'" + " AND dur=" + pp_1hr_dur + " AND ts='"
|
||||
+ ts + "' AND extremum='Z'" + " AND obstime='"
|
||||
+ sdf.format(datetime) + "'";
|
||||
+ sdf.format(dt.getTime()) + "'";
|
||||
MPEDataManager.getInstance().updateRawPP(where);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -269,7 +269,7 @@ public class FFMPGuidanceBasin extends FFMPBasin implements ISerializableObject
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Youngest Key
|
||||
* Get Closest Key
|
||||
*
|
||||
* @param sourceName
|
||||
* @param Date
|
||||
|
@ -308,19 +308,16 @@ public class FFMPGuidanceBasin extends FFMPBasin implements ISerializableObject
|
|||
// as long as it is +- expiration from orig date,
|
||||
// golden
|
||||
if (date.after(checkDate)) {
|
||||
if ((time1 - time2) > expiration) {
|
||||
if ((time1 - time2) < expiration) {
|
||||
rdate = checkDate;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if ((time2 - time1) > expiration) {
|
||||
if ((time2 - time1) < expiration) {
|
||||
rdate = checkDate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
rdate = checkDate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1584,6 +1584,11 @@ public class FFMPGenerator extends CompositeProductGenerator implements
|
|||
|
||||
try {
|
||||
|
||||
File sharePathFile = new File(sharePath + config.getCWA());
|
||||
if (!sharePathFile.exists()) {
|
||||
sharePathFile.mkdirs();
|
||||
}
|
||||
|
||||
String fileName = fdc.getFilePath();
|
||||
// lock for atomic write and read
|
||||
HashMap<String, String> fileNames = new HashMap<String, String>();
|
||||
|
@ -1655,15 +1660,15 @@ public class FFMPGenerator extends CompositeProductGenerator implements
|
|||
for (String tmpName : fileNames.keySet()) {
|
||||
File file = new File(tmpName);
|
||||
if (file.renameTo(new File(fileNames.get(tmpName)))) {
|
||||
statusHandler
|
||||
.handle(Priority.DEBUG,
|
||||
statusHandler.handle(
|
||||
Priority.DEBUG,
|
||||
"Successful rename: : "
|
||||
+fileNames.get(tmpName));
|
||||
+ fileNames.get(tmpName));
|
||||
} else {
|
||||
statusHandler
|
||||
.handle(Priority.ERROR,
|
||||
statusHandler.handle(
|
||||
Priority.ERROR,
|
||||
"UN-Successful rename: : "
|
||||
+fileNames.get(tmpName));
|
||||
+ fileNames.get(tmpName));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1683,7 +1688,6 @@ public class FFMPGenerator extends CompositeProductGenerator implements
|
|||
statusHandler.handle(Priority.ERROR,
|
||||
"IO Error writing buddy files: " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue