001/* 002 * This file is part of McIDAS-V 003 * 004 * Copyright 2007-2017 005 * Space Science and Engineering Center (SSEC) 006 * University of Wisconsin - Madison 007 * 1225 W. Dayton Street, Madison, WI 53706, USA 008 * https://www.ssec.wisc.edu/mcidas 009 * 010 * All Rights Reserved 011 * 012 * McIDAS-V is built on Unidata's IDV and SSEC's VisAD libraries, and 013 * some McIDAS-V source code is based on IDV and VisAD source code. 014 * 015 * McIDAS-V is free software; you can redistribute it and/or modify 016 * it under the terms of the GNU Lesser Public License as published by 017 * the Free Software Foundation; either version 3 of the License, or 018 * (at your option) any later version. 019 * 020 * McIDAS-V is distributed in the hope that it will be useful, 021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 023 * GNU Lesser Public License for more details. 024 * 025 * You should have received a copy of the GNU Lesser Public License 026 * along with this program. If not, see http://www.gnu.org/licenses. 027 */ 028 029package edu.wisc.ssec.mcidasv.adt; 030 031import java.lang.Math; 032import java.lang.String; 033 034public class MWAdj { 035 036 public MWAdj() { 037 } 038 039 public static double[] adt_calcmwadjustment(double MWScoreInput, 040 double IntensityEstimateValueInput) { 041 042 int MWScoreApplicationFlag = 0; 043 int XInc; 044 int NumRecsHistory = History.HistoryNumberOfRecords(); 045 int RecDate,RecTime,RecLand; 046 int RecMWDate,RecMWTime; 047 int Rule8Flag = 0;; 048 int LastCloudSceneValue; 049 int LastRule8Flag = 0;; 050 int NonEIRSceneCounter = 0; 051 int LastEyeSceneValue = 0; 052 double IntensityEstimateValueReturn = IntensityEstimateValueInput; 053 double InputIntensityEstStore = IntensityEstimateValueInput; 054 double MWScoreThresholdValue1 = 20.0; 055 double MWScoreThresholdValue2 = 60.0; 056 double MWIntensityTnoValue1 = 4.3; 057 double MWIntensityTnoValue1a = 4.8; 058 double MWIntensityTnoValue2 = 5.0; 059 double RecMWScore; 060 double Traw; 061 double PreviousMWScoreValue; 062 double HistoryRecTime = 0.0; 063 double LastCIValue = 1.0; 064 double FirstMWHoldTime = 0.0; 065 double LastValidMWCIValue = 0.0; 066 double LastMWScoreValue = 0.0; 067 double FirstHistoryCIValue = 0.0; 068 double FirstMWadjTime = 0.0; 069 double FirstMWadjTimePlus12hr = 0.0; 070 double LastValidMWadjTime = 0.0; 071 double LastValidMWadjTimePlus6 = 0.0; 072 double HistoryCIValue = 0.0; 073 double HistoryCIValueMinus12hr= 0.0; 074 double HistoryRecTimeMinus12hr = 0.0; 075 double InterpTimePart,IntensityCIMergeValue,NewIntensityEstScore; 076 boolean LandCheckTF = true; 077 boolean FirstMWHoldTF = true; 078 boolean EXIT_Routine = false; 079 boolean MWAdjOFFTF = false; 080 boolean FoundHistoryRecPrev12hrTF = false; 081 boolean First31Record = true; 082 boolean MWAdjCurrentONTF = false; 083 boolean NORecordAfterMWTimeTF = true; 084 String CommentString = ""; 085 086 boolean LandFlagTF = Env.LandFlagTF; 087 088 int CurDate = History.IRCurrentRecord.date; 089 int CurTime = History.IRCurrentRecord.time; 090 int CurCloudScene = History.IRCurrentRecord.cloudscene; 091 int CurEyeScene = History.IRCurrentRecord.eyescene; 092 int CurLand = History.IRCurrentRecord.land; 093 double CurrentTime = Functions.calctime(CurDate,CurTime); 094 095 System.out.printf("INPUT current mw env score=%f date=%d time=%d\n",MWScoreInput, Env.MWJulianDate, Env.MWHHMMSSTime ); 096 /* check for valid MW eye score value (not equal to -920) */ 097 if(MWScoreInput<-900.0) { 098 if(Env.DEBUG==100) { 099 System.out.printf("MW SCORE=-920 ... will restore to previous valid record"); 100 } 101 XInc = 0; 102 while(XInc<NumRecsHistory) { 103 RecDate = History.HistoryFile[XInc].date; 104 RecTime = History.HistoryFile[XInc].time; 105 HistoryRecTime = Functions.calctime(RecDate,RecTime); 106 107 RecLand = History.HistoryFile[XInc].land; 108 Traw = History.HistoryFile[XInc].Traw; 109 LandCheckTF = true; 110 if(((LandFlagTF)&&(RecLand==1))||(Traw<1.0)) { 111 LandCheckTF = false; 112 } 113 if(LandCheckTF) { 114 RecMWDate = History.HistoryFile[XInc].mwdate; 115 RecMWTime = History.HistoryFile[XInc].mwtime; 116 RecMWScore = History.HistoryFile[XInc].mwscore; 117 MWScoreInput = RecMWScore; 118 History.IRCurrentRecord.mwdate = RecMWDate; 119 History.IRCurrentRecord.mwtime = RecMWTime; 120 History.IRCurrentRecord.mwscore = RecMWScore; 121 Env.MWJulianDate = RecMWDate; 122 Env.MWHHMMSSTime = RecMWTime; 123 Env.MWScore = RecMWScore; 124 } 125 XInc++; 126 } 127 } 128 129 /* determine MW score flag and value */ 130 if(MWScoreInput>=MWScoreThresholdValue1) { 131 MWScoreApplicationFlag = 1; 132 } 133 if((MWScoreInput>=MWScoreThresholdValue1)&& 134 (MWScoreInput<=MWScoreThresholdValue2)) { 135 IntensityEstimateValueReturn = MWIntensityTnoValue1+0.01; 136 } 137 if(MWScoreInput>=MWScoreThresholdValue2) { 138 IntensityEstimateValueReturn = MWIntensityTnoValue2+0.01; 139 } 140 141 int MWJulianDateGlobal = Env.MWJulianDate; 142 int MWTimeGlobal = Env.MWHHMMSSTime; 143 if(Env.DEBUG==100) { 144 System.out.printf("MW DATE=%d TIME=%d\n",MWJulianDateGlobal,MWTimeGlobal); 145 } 146 147 double CurrentMWTime = Functions.calctime(MWJulianDateGlobal,MWTimeGlobal); 148 149 double CurrentMWTimeMinus12hr = CurrentMWTime-0.5; 150 double CurrentMWTimePlus12hr = CurrentMWTime+0.5; 151 double CurrentMWTimePlus6hr = CurrentMWTime+0.25; 152 153 if(Env.DEBUG==100) { 154 System.out.printf("MWScoreInput=%f *IntensityEstimateValue_Return=%f\n", 155 MWScoreInput,IntensityEstimateValueReturn); 156 System.out.printf("CurrentTime=%f CurrentMWTime=%f CurrentMWTimePlus12hr=%f\n", 157 CurrentTime,CurrentMWTime,CurrentMWTimePlus12hr); 158 } 159 160 /* redo MW score logic */ 161 if(CurrentTime>CurrentMWTimePlus12hr) { 162 MWScoreApplicationFlag = 0; 163 } 164 165 /* NEW LOGIC 166 - If last valid MW overpass time is greater than 8 hours old, then MW HOLD 167 -- If, while in MW HOLD pattern we get three shear scenes, turn MW OFF 168 -- If in MW HOLD for greater than or equal to 6 hours, turn MW OFF 169 - Will NOT check for three shear scenes if in MW ON 170 */ 171 172 if((CurrentTime-CurrentMWTime)>.3333) { 173 /* MW record is > 8 hours old... start new Shear/HOLD checking logic */ 174 if(Env.DEBUG==100) { 175 System.out.printf("MW record > 8 hours old... new logic CurrentTime=%f CurrentMWTime=%f\n",CurrentTime,CurrentMWTime); 176 } 177 178 /* First... loop through history file records */ 179 XInc = 0; 180 while(XInc<NumRecsHistory) { 181 RecDate = History.HistoryFile[XInc].date; 182 RecTime = History.HistoryFile[XInc].time; 183 HistoryRecTime = Functions.calctime(RecDate,RecTime); 184 185 RecLand = History.HistoryFile[XInc].land; 186 Traw = History.HistoryFile[XInc].Traw; 187 LandCheckTF = true; 188 if(((LandFlagTF)&&(RecLand==1))||(Traw<1.0)) { 189 LandCheckTF = false; 190 } 191 192 if(LandCheckTF) { 193 if(HistoryRecTime<CurrentTime) { 194 LastCloudSceneValue = History.HistoryFile[XInc].cloudscene; 195 LastRule8Flag = History.HistoryFile[XInc].rule8; 196 LastValidMWCIValue = History.HistoryFile[XInc].CI; 197 NonEIRSceneCounter = (LastCloudSceneValue>=4) ? NonEIRSceneCounter+1 : 0; 198 if(Env.DEBUG==100) { 199 System.out.printf("time=%f nonEIRscenecounter=%d\n",HistoryRecTime,NonEIRSceneCounter); 200 } 201 if(LastRule8Flag==33) { 202 if(FirstMWHoldTF) { 203 FirstMWHoldTime = HistoryRecTime; 204 FirstMWHoldTF = false; 205 } 206 } else { 207 FirstMWHoldTime = HistoryRecTime; 208 FirstMWHoldTF = true; 209 } 210 } 211 } 212 XInc++; 213 } 214 215 /* now check for current shear scene and previous MW ON */ 216 if(LastRule8Flag==32) { 217 EXIT_Routine = true; 218 /* previous MW ON... set to HOLD */ 219 History.IRCurrentRecord.rule8 = 33; /* HOLD */ 220 if(Env.DEBUG==100) { 221 System.out.printf("previous MW on... now MW HOLD: nonEIRscenecounter=%d\n",NonEIRSceneCounter); 222 } 223 IntensityEstimateValueReturn = LastValidMWCIValue; 224 MWScoreApplicationFlag = 1; 225 /* check to see if current record is shear scene and had two shears before it... 226 if so... turn MW OFF */ 227 if((NonEIRSceneCounter>=2)&&(CurCloudScene==4)) { 228 if(Env.DEBUG==100) { 229 System.out.printf("Third consecutive SHEAR scene... turning OFF!!!\n"); 230 } 231 /* >= three consecutive non-EIR eye scenes and would have been MW HOLD... turn OFF */ 232 IntensityEstimateValueReturn = InputIntensityEstStore; 233 History.IRCurrentRecord.rule8 = 34; /* OFF */ 234 MWScoreApplicationFlag = 0; 235 } 236 /* end possible remove section */ 237 } else if (LastRule8Flag==33) { 238 EXIT_Routine = true; 239 if(Env.DEBUG==100) { 240 System.out.printf("current MW HOLD... nonEIRscene=%d cloudscene=%d\n",NonEIRSceneCounter,CurCloudScene); 241 } 242 /* was in MW HOLD... now checking for shear scenes to turn MW OFF */ 243 if((NonEIRSceneCounter>=2)&&(CurCloudScene==4)) { 244 if(Env.DEBUG==100) { 245 System.out.printf("current MW HOLD... third consecutive SHEAR scene... turning OFF!!!\n"); 246 } 247 /* >= three consecutive non-EIR eye scenes and was in MW HOLD... turn OFF */ 248 IntensityEstimateValueReturn = InputIntensityEstStore; 249 History.IRCurrentRecord.rule8 = 34; /* OFF */ 250 MWScoreApplicationFlag = 0; 251 } else { 252 History.IRCurrentRecord.rule8 = 33; /* HOLD */ 253 IntensityEstimateValueReturn = LastValidMWCIValue; 254 MWScoreApplicationFlag = 1; 255 if(Env.DEBUG==100) { 256 System.out.printf("current MW HOLD... keep HOLD\n"); 257 } 258 if((CurrentTime-FirstMWHoldTime)>=.25) { 259 /* in MW HOLD >= 6 hours... turn OFF */ 260 IntensityEstimateValueReturn = InputIntensityEstStore; 261 History.IRCurrentRecord.rule8 = 34; /* OFF */ 262 MWScoreApplicationFlag = 0; 263 264 CommentString = String.format("MW OFF HOLD >=6hrs old",CommentString); 265 History.IRCurrentRecord.comment = CommentString; 266 if(Env.DEBUG==100) { 267 System.out.printf("current MW HOLD... in HOLD >= 6 hours... turning OFF!!!\n"); 268 } 269 } 270 } 271 } 272 else if (LastRule8Flag==34) { 273 MWScoreApplicationFlag = 0; 274 IntensityEstimateValueReturn = InputIntensityEstStore; 275 EXIT_Routine = true; 276 if(Env.DEBUG==100) { 277 System.out.printf("last record MW OFF.... returning\n"); 278 } 279 } else { 280 /* do nothing */ 281 MWScoreApplicationFlag = 0; 282 IntensityEstimateValueReturn = InputIntensityEstStore; 283 EXIT_Routine = true; 284 if(Env.DEBUG==100) { 285 System.out.printf("old MW record.... returning\n"); 286 } 287 } 288 /* END NEW LOGIC */ 289 } else { 290 /* check for three consecutive eyes */ 291 int EyeSceneCounter = 0; 292 LastCIValue = 1.0; 293 XInc = 0; 294 while(XInc<NumRecsHistory) { 295 RecDate = History.HistoryFile[XInc].date; 296 RecTime = History.HistoryFile[XInc].time; 297 HistoryRecTime = Functions.calctime(RecDate,RecTime); 298 299 RecLand = History.HistoryFile[XInc].land; 300 Traw = History.HistoryFile[XInc].Traw; 301 LandCheckTF = true; 302 if(((LandFlagTF)&&(RecLand==1))||(Traw<1.0)) { 303 LandCheckTF = false; 304 } 305 306 if(LandCheckTF) { 307 if(HistoryRecTime<CurrentTime) { 308 /* 309 * added time check for LastCIValue to make sure MW eye adjustment doesn't 310 * reset at a time after the MW time once the CI falls below 4.0 (after the 311 * MW adjustment had been on but had turned off for whatever reason)... the 312 * CI# must be below 4.0 when the current MW score is implemented at 313 * or before the current MW time for this to be reset 314 */ 315 if(HistoryRecTime<CurrentMWTime) { 316 LastCIValue = History.HistoryFile[XInc].CI; 317 } 318 LastEyeSceneValue = History.HistoryFile[XInc].eyescene; 319 LastRule8Flag = History.HistoryFile[XInc].rule8; 320 EyeSceneCounter = (LastEyeSceneValue<=2) ? EyeSceneCounter+1 : 0; 321 if(Env.DEBUG==100) { 322 System.out.printf("time=%f eyescenecounter=%d LastCIValue=%f\n", 323 HistoryRecTime,EyeSceneCounter,LastCIValue); 324 } 325 if(EyeSceneCounter>=3) MWAdjOFFTF = true; 326 } 327 } 328 /* 329 * turn back on MW adjustment if CI falls below 4.0. 330 * had to modifiy because if MW adjustment goes on after "reset" 331 * and CI#s are modified when a new MW adjustment goes on, the 332 * eye check from a previous period will still tell ADT to turn 333 * off MW adjustment even though it was reset. Checking for Rule8 334 * value of 31 will indicate that the MW was turned back on correctly 335 * and to start new checking for eyes after that point. 336 */ 337 if((LastCIValue<4.0||LastRule8Flag==31)) { 338 if(Env.DEBUG==100) { 339 System.out.printf("CI below 4.0... resetting MW adjustment!!! LastCIValue=%f\n",LastCIValue); 340 } 341 MWAdjOFFTF = false; 342 } 343 XInc++; 344 } 345 if(Env.DEBUG==100) { 346 System.out.printf("current eye scene=%d\n",CurEyeScene); 347 } 348 if(CurEyeScene<=2) { 349 EyeSceneCounter++; 350 if(Env.DEBUG==100) { 351 System.out.printf("time=%f eyescenecounter=%d\n",CurrentTime,EyeSceneCounter); 352 } 353 if (EyeSceneCounter>=3) MWAdjOFFTF = true; 354 } 355 if(MWAdjOFFTF) { 356 /* found three consecutive eyes... return immediately */ 357 if(Env.DEBUG==100) { 358 System.out.printf("FOUND THREE EYES... EXITING!!! LastCIValue=%f\n",LastCIValue); 359 } 360 if((LastRule8Flag>=30)&&(LastRule8Flag<=33)) { 361 History.IRCurrentRecord.rule8 = 34; /* OFF */ 362 } 363 IntensityEstimateValueReturn = InputIntensityEstStore; 364 EXIT_Routine = true; 365 MWScoreApplicationFlag = 0; 366 } 367 } 368 if(Env.DEBUG==100) { 369 System.out.printf("1 EXIT_Routine=%b\n",EXIT_Routine); 370 } 371 372 /* check for THREE hours of land interaction... turn MW off this occurs 373 changed from six hours on 7 June 2013 per Velden recommendation */ 374 LastRule8Flag=0; 375 if(Env.DEBUG==100) { 376 System.out.printf("CHECKING LAND INTERACTION\n"); 377 } 378 double LastNonLandTime = 0.0; 379 boolean MWLandCheckTF = false; 380 XInc = 0; 381 while(XInc<NumRecsHistory) { 382 RecDate = History.HistoryFile[XInc].date; 383 RecTime = History.HistoryFile[XInc].time; 384 HistoryRecTime = Functions.calctime(RecDate,RecTime); 385 386 RecLand = History.HistoryFile[XInc].land; 387 Traw = History.HistoryFile[XInc].Traw; 388 LandCheckTF = true; 389 if(((LandFlagTF)&&(RecLand==1))||(Traw<1.0)) { 390 LandCheckTF = false; 391 } 392 393 if(!LandCheckTF) { /* TC over land */ 394 if(Env.DEBUG==100) { 395 System.out.printf("OVER LAND SINCE %f FOR %f DAYS \n",LastNonLandTime,(HistoryRecTime-LastNonLandTime)); 396 } 397 if((HistoryRecTime-LastNonLandTime)>=0.125) { 398 MWLandCheckTF = true; 399 MWAdjOFFTF = false; 400 if(Env.DEBUG==100) { 401 System.out.printf("RESETTING MWAdjOFFTF Flag\n"); 402 } 403 } 404 } else { 405 LastRule8Flag = History.HistoryFile[XInc].rule8; 406 LastNonLandTime = HistoryRecTime; 407 MWLandCheckTF = false; 408 } 409 if(Env.DEBUG==100) { 410 System.out.printf("MWLandCheckTF=%b\n",MWLandCheckTF); 411 } 412 XInc++; 413 } 414 if(Env.DEBUG==100) { 415 System.out.printf("2 EXIT_Routine=%b\n",EXIT_Routine); 416 } 417 if(Env.DEBUG==100) { 418 System.out.printf("MWLandCheckTF=%b LandFlag=%d LastRule8Flag=%d\n",MWLandCheckTF,CurLand,LastRule8Flag); 419 } 420 if((MWLandCheckTF)&&(CurLand==2)) { 421 if((LastRule8Flag>=30)&&(LastRule8Flag<=33)) { 422 if(Env.DEBUG==100) { 423 System.out.printf("OVER LAND FOR MORE THAN 3 HOURS... TURNING OFF ME AND EXITING!!!\n"); 424 } 425 History.IRCurrentRecord.rule8 = 34; /* OFF */ 426 IntensityEstimateValueReturn = InputIntensityEstStore; 427 EXIT_Routine = true; 428 MWScoreApplicationFlag = 0; 429 } 430 } 431 /* End Land Check */ 432 433 if(Env.DEBUG==100) { 434 System.out.printf("3 EXIT_Routine=%b\n",EXIT_Routine); 435 } 436 437 if(!EXIT_Routine) { 438 /* check previous history record values */ 439 XInc = 0; 440 while(XInc<NumRecsHistory) { 441 RecDate = History.HistoryFile[XInc].date; 442 RecTime = History.HistoryFile[XInc].time; 443 HistoryRecTime = Functions.calctime(RecDate,RecTime); 444 445 if(HistoryRecTime<CurrentMWTime) { 446 447 RecLand = History.HistoryFile[XInc].land; 448 Traw = History.HistoryFile[XInc].Traw; 449 LandCheckTF = true; 450 if(((LandFlagTF)&&(RecLand==1))||(Traw<1.0)) { 451 LandCheckTF = false; 452 } 453 454 if(LandCheckTF) { /* TC over land */ 455 /* check to see if current MW adjustment was on previous 456 ** to current MW entry date/time */ 457 LastMWScoreValue = History.HistoryFile[XInc].mwscore; 458 LastValidMWCIValue = History.HistoryFile[XInc].CI; 459 Rule8Flag = History.HistoryFile[XInc].rule8; 460 if(Env.DEBUG==100) { 461 System.out.printf("Time=%f previous MW record: lastscore=%f lasteye=%d rule8=%d\n", 462 HistoryRecTime,LastMWScoreValue,LastEyeSceneValue,Rule8Flag); 463 } 464 465 MWAdjCurrentONTF = false; 466 if((Rule8Flag>=31)&&(Rule8Flag<=33)) { 467 MWAdjCurrentONTF = true; 468 if((Rule8Flag>=31)&&(First31Record)) { 469 if(Env.DEBUG==100) { 470 System.out.printf("found 31 in previous record search!\n"); 471 } 472 FirstHistoryCIValue = History.HistoryFile[XInc].CI; 473 FirstMWadjTime = HistoryRecTime; 474 FirstMWadjTimePlus12hr = FirstMWadjTime+0.5; 475 First31Record = false; 476 } 477 } else { 478 First31Record = true; /* reset mark for MW score merging */ 479 } 480 if((Rule8Flag>=30)&&(Rule8Flag<=32)) { 481 LastValidMWCIValue = History.HistoryFile[XInc].CI; 482 LastValidMWadjTime = HistoryRecTime; 483 LastValidMWadjTimePlus6 = HistoryRecTime+0.25; 484 } 485 } 486 } 487 XInc++; 488 } 489 490 LastRule8Flag = Rule8Flag; 491 PreviousMWScoreValue = LastMWScoreValue; 492 493 if(Env.DEBUG==100) { 494 System.out.printf("FirstHistoryCIValue=%f First31Record=%b\n",FirstHistoryCIValue,First31Record); 495 System.out.printf("FirstMWadjTime=%f FirstMWadjTimePlus12hr=%f\n",FirstMWadjTime,FirstMWadjTimePlus12hr); 496 } 497 /* BEFORE MW TIME */ 498 if(Env.DEBUG==100) { 499 System.out.printf("MWAdjCurrentONTF=%b MWScoreApplicationFlag=%d\n",MWAdjCurrentONTF,MWScoreApplicationFlag); 500 } 501 if((!MWAdjCurrentONTF)&&(MWScoreApplicationFlag==0)) { 502 /* MW was OFF and is still OFF */ 503 if(Env.DEBUG==100) { 504 System.out.printf("OFF - OFF\n"); 505 } 506 /* I still need to put the mw value into all records after the mw input time */ 507 XInc = 0; 508 while(XInc<NumRecsHistory) { 509 RecDate = History.HistoryFile[XInc].date; 510 RecTime = History.HistoryFile[XInc].time; 511 HistoryRecTime = Functions.calctime(RecDate,RecTime); 512 if(HistoryRecTime>=CurrentMWTime) { 513 /* determine if there is a record after MW time */ 514 NORecordAfterMWTimeTF = false; 515 } 516 XInc++; 517 } 518 } else if((!MWAdjCurrentONTF)&&(MWScoreApplicationFlag==1)) { 519 /* MW was OFF but is now ON */ 520 if(Env.DEBUG==100) { 521 System.out.printf("OFF - now ON\n"); 522 } 523 524 XInc = 0; 525 while(XInc<NumRecsHistory) { 526 RecDate = History.HistoryFile[XInc].date; 527 RecTime = History.HistoryFile[XInc].time; 528 HistoryRecTime = Functions.calctime(RecDate,RecTime); 529 if(Env.DEBUG==100) { 530 System.out.printf("HistoryRecTime=%f CurrentMWTime=%f\n",HistoryRecTime,CurrentMWTime); 531 } 532 if(HistoryRecTime<CurrentMWTime) { 533 /* merge backwards 12 hours previous to MW time */ 534 RecLand = History.HistoryFile[XInc].land; 535 Traw = History.HistoryFile[XInc].Traw; 536 LandCheckTF = true; 537 if(((LandFlagTF)&&(RecLand==1))||(Traw<1.0)) { 538 LandCheckTF = false; 539 } 540 541 if(LandCheckTF) { 542 HistoryCIValue = History.HistoryFile[XInc].CI; 543 Rule8Flag = History.HistoryFile[XInc].rule8; 544 if(HistoryRecTime>=CurrentMWTimeMinus12hr) { 545 if(!FoundHistoryRecPrev12hrTF) { 546 FoundHistoryRecPrev12hrTF = true; 547 HistoryCIValueMinus12hr = HistoryCIValue; 548 HistoryRecTimeMinus12hr = HistoryRecTime; 549 } 550 /* 551 * interpolate value between current value and 552 * 12 hour previous value 553 */ 554 if(Rule8Flag!=30) { 555 CommentString = "" ; 556 CommentString = String.format("MWinit1=%3.1f/%3.1f/%3.1f", 557 History.HistoryFile[XInc].Traw, 558 History.HistoryFile[XInc].Tfinal, 559 History.HistoryFile[XInc].CI); 560 InterpTimePart = (HistoryRecTime-HistoryRecTimeMinus12hr)/ 561 (CurrentMWTime-HistoryRecTimeMinus12hr); 562 IntensityCIMergeValue = Math.max(IntensityEstimateValueReturn,HistoryCIValueMinus12hr); 563 NewIntensityEstScore = ((IntensityCIMergeValue-HistoryCIValueMinus12hr)*InterpTimePart)+ 564 HistoryCIValueMinus12hr; 565 History.HistoryFile[XInc].Traw = NewIntensityEstScore; 566 History.HistoryFile[XInc].Tfinal = NewIntensityEstScore; 567 History.HistoryFile[XInc].CI = NewIntensityEstScore; 568 History.HistoryFile[XInc].rule8 = 30; 569 History.HistoryFile[XInc].comment = CommentString; 570 if(Env.DEBUG==100) { 571 System.out.printf("rule8=30 Time=%f NewIntensityEstScore=%f\n",HistoryRecTime,NewIntensityEstScore); 572 } 573 } else { 574 if(Env.DEBUG==100) { 575 System.out.printf("already merged backwards... skipping\n"); 576 } 577 } 578 } 579 } 580 LastValidMWCIValue = History.HistoryFile[XInc].CI; 581 LastRule8Flag = 30; 582 } else { 583 /* determine if there is a record after MW time */ 584 NORecordAfterMWTimeTF = false; 585 } 586 XInc++; 587 } 588 } else if((MWAdjCurrentONTF)&&(MWScoreApplicationFlag==1)) { 589 /* MW was ON and is still ON */ 590 if(Env.DEBUG==100) { 591 System.out.printf("ON - still ON\n"); 592 } 593 594 XInc = 0; 595 while(XInc<NumRecsHistory) { 596 RecDate = History.HistoryFile[XInc].date; 597 RecTime = History.HistoryFile[XInc].time; 598 HistoryRecTime = Functions.calctime(RecDate,RecTime); 599 if(Env.DEBUG==100) { 600 System.out.printf("PreviousMWScoreValue=%f IntensityEstimateValue_Ret=%f\n", 601 PreviousMWScoreValue,IntensityEstimateValueReturn); 602 } 603 if(HistoryRecTime<CurrentMWTime) { 604 if(Env.DEBUG==100) { 605 System.out.printf("HistoryRecTime=%f CurrentMWTime=%f : LastMWScoreValue=%f *IntensityEstimateValue_Ret=%f\n", 606 HistoryRecTime,CurrentMWTime,LastMWScoreValue,IntensityEstimateValueReturn); 607 } 608 /* merge backwards from 4.3/4.8 to 5.0, if necessary */ 609 if((LastMWScoreValue<MWScoreThresholdValue2)&&(IntensityEstimateValueReturn>=MWIntensityTnoValue2)) { 610 /* merge backwards 12 hours previous to MW time */ 611 RecLand = History.HistoryFile[XInc].land; 612 Traw = History.HistoryFile[XInc].Traw; 613 LandCheckTF = true; 614 if(((LandFlagTF)&&(RecLand==1))||(Traw<1.0)) { 615 LandCheckTF = false; 616 } 617 if(LandCheckTF) { 618 HistoryCIValue = History.HistoryFile[XInc].CI; 619 Rule8Flag = History.HistoryFile[XInc].rule8; 620 CommentString = History.HistoryFile[XInc].comment; 621 if(Env.DEBUG==100) { 622 System.out.printf("CommentString=%s**%d\n",CommentString,CommentString.length()); 623 } 624 if(HistoryRecTime>=CurrentMWTimeMinus12hr) { 625 if(!FoundHistoryRecPrev12hrTF) { 626 FoundHistoryRecPrev12hrTF = true; 627 HistoryCIValueMinus12hr = HistoryCIValue; 628 HistoryRecTimeMinus12hr = HistoryRecTime; 629 if(Env.DEBUG==100) { 630 System.out.printf("historyminus12 CI=%f time=%f\n",HistoryCIValueMinus12hr,HistoryRecTimeMinus12hr); 631 } 632 } 633 if(CommentString.length()==0) { 634 /* 635 * interpolate value between current value and 636 * 12 hour previous value 637 */ 638 CommentString = ""; 639 CommentString = String.format("MWinit2=%3.1f/%3.1f/%3.1f", 640 History.HistoryFile[XInc].Traw, 641 History.HistoryFile[XInc].Tfinal, 642 History.HistoryFile[XInc].CI); 643 History.HistoryFile[XInc].comment = CommentString; 644 } 645 InterpTimePart = (HistoryRecTime-HistoryRecTimeMinus12hr)/ 646 (CurrentMWTime-HistoryRecTimeMinus12hr); 647 NewIntensityEstScore = ((IntensityEstimateValueReturn-HistoryCIValueMinus12hr)*InterpTimePart)+ 648 HistoryCIValueMinus12hr; 649 History.HistoryFile[XInc].Traw = NewIntensityEstScore; 650 History.HistoryFile[XInc].Tfinal = NewIntensityEstScore; 651 History.HistoryFile[XInc].CI = NewIntensityEstScore; 652 Rule8Flag = History.HistoryFile[XInc].rule8; 653 if(Rule8Flag>=32) { 654 History.HistoryFile[XInc].rule8 = 32; 655 } 656 if(Env.DEBUG==100) { 657 System.out.printf("rule8=32 Time=%f NewIntensityEstScore=%f\n",HistoryRecTime,NewIntensityEstScore); 658 } 659 } 660 } 661 } else { 662 /* merge backwards from 4.3 to 4.8 AFTER HOLD when MW > threshold, if necessary */ 663 if((LastMWScoreValue<MWScoreThresholdValue1)&& 664 (MWScoreInput>=MWScoreThresholdValue1)) { 665 CommentString = History.HistoryFile[XInc].comment; 666 Rule8Flag = History.HistoryFile[XInc].rule8; 667 if(Env.DEBUG==100) { 668 System.out.printf("merge backwards - WAS IN HOLD, now back on\n"); 669 } 670 /* merge backwards 12 hours previous to MW time */ 671 RecLand = History.HistoryFile[XInc].land; 672 Traw = History.HistoryFile[XInc].Traw; 673 LandCheckTF = true; 674 if(((LandFlagTF)&&(RecLand==1))||(Traw<1.0)) { 675 LandCheckTF = false; 676 } 677 if(LandCheckTF) { 678 if(HistoryRecTime>=FirstMWadjTime) { 679 if(Rule8Flag==33) { 680 /* 681 * interpolate value between current value and 682 * 12 hour previous value 683 */ 684 if(CommentString.length()==0) { 685 CommentString = ""; 686 CommentString = String.format("MWinit3=%3.1f/%3.1f/%3.1f", 687 History.HistoryFile[XInc].Traw, 688 History.HistoryFile[XInc].Tfinal, 689 History.HistoryFile[XInc].CI); 690 History.HistoryFile[XInc].comment = CommentString; 691 } 692 InterpTimePart = (HistoryRecTime-FirstMWadjTime)/ 693 (FirstMWadjTimePlus12hr-FirstMWadjTime); 694 InterpTimePart = Math.min(1.0,InterpTimePart); 695 NewIntensityEstScore = ((MWIntensityTnoValue1a-FirstHistoryCIValue)*InterpTimePart)+ 696 FirstHistoryCIValue; 697 History.HistoryFile[XInc].Traw = NewIntensityEstScore; 698 History.HistoryFile[XInc].Tfinal = NewIntensityEstScore; 699 History.HistoryFile[XInc].CI = NewIntensityEstScore; 700 Rule8Flag = History.HistoryFile[XInc].rule8; 701 if(Rule8Flag>=32) { 702 History.HistoryFile[XInc].rule8 = 32; 703 } 704 if(Env.DEBUG==100) { 705 System.out.printf("changing to rule8=32 Time=%f NewIntensityEstScore=%f\n", 706 HistoryRecTime,NewIntensityEstScore); 707 } 708 } else { 709 if(Env.DEBUG==100) { 710 System.out.printf("ALREADY INTERPOLATED BACKWARDS... SKIPPING\n"); 711 } 712 } 713 } 714 } 715 } 716 } 717 LastValidMWCIValue = History.HistoryFile[XInc].CI; 718 } else { 719 /* determine if there is a record after MW time */ 720 NORecordAfterMWTimeTF = false; 721 } 722 XInc++; 723 } 724 } else if((MWAdjCurrentONTF)&&(MWScoreApplicationFlag==0)) { 725 /* MW was ON and is now OFF */ 726 if(Env.DEBUG==100) { 727 System.out.printf("ON - now OFF\n"); 728 } 729 XInc = 0; 730 while(XInc<NumRecsHistory) { 731 RecDate = History.HistoryFile[XInc].date; 732 RecTime = History.HistoryFile[XInc].time; 733 HistoryRecTime = Functions.calctime(RecDate,RecTime); 734 if(HistoryRecTime>=CurrentMWTime) { 735 /* determine if there is a record after MW time */ 736 NORecordAfterMWTimeTF = false; 737 } 738 XInc++; 739 } 740 } else { 741 /* nothing */ 742 if(Env.DEBUG==100) { 743 System.out.printf("nothing\n"); 744 } 745 } 746 747 if(Env.DEBUG==100) { 748 System.out.printf("LastValidMWCIValue=%f\n",LastValidMWCIValue); 749 } 750 751 /* AFTER MW TIME */ 752 if(Env.DEBUG==100) { 753 System.out.printf("NORecordAfterMWTimeTF=%b\n",NORecordAfterMWTimeTF); 754 } 755 if(!NORecordAfterMWTimeTF) { 756 /* first record after MW time is not current record... 757 * do necessary processing to records in between 758 * MW time and up to current record 759 */ 760 if(Env.DEBUG==100) { 761 System.out.printf("CURRENT RECORD IS NOT LAST\n"); 762 } 763 XInc = 0; 764 while(XInc<NumRecsHistory) { 765 /* handle all records after input MW time */ 766 RecDate = History.HistoryFile[XInc].date; 767 RecTime = History.HistoryFile[XInc].time; 768 HistoryRecTime = Functions.calctime(RecDate,RecTime); 769 if(Env.DEBUG==100) { 770 System.out.printf("HistoryRecTime=%f CurrentMWTime=%f\n",HistoryRecTime,CurrentMWTime); 771 } 772 Rule8Flag = History.HistoryFile[XInc].rule8; 773 if(Rule8Flag==34) LastRule8Flag = 34; 774 RecLand = History.HistoryFile[XInc].land; 775 Traw = History.HistoryFile[XInc].Traw; 776 LandCheckTF = true; 777 if(((LandFlagTF)&&(RecLand==1))||(Traw<1.0)) { 778 LandCheckTF = false; 779 } 780 if(LandCheckTF) { 781 if(HistoryRecTime>=CurrentMWTime) { 782 if(Env.DEBUG==100) { 783 System.out.printf("LastRule8Flag=%d\n",LastRule8Flag); 784 } 785 switch (LastRule8Flag) { 786 case 30: 787 if(Env.DEBUG==100) { 788 System.out.printf("rule8 was 30 current is 31\n"); 789 } 790 History.HistoryFile[XInc].rule8 = 32; 791 /* should set value right after MW time to 4.3/4.8 */ 792 LastValidMWCIValue = Math.max(IntensityEstimateValueReturn,LastValidMWCIValue); 793 History.HistoryFile[XInc].Traw = LastValidMWCIValue; 794 History.HistoryFile[XInc].Tfinal = LastValidMWCIValue; 795 History.HistoryFile[XInc].CI = LastValidMWCIValue; 796 LastValidMWadjTime = HistoryRecTime; 797 LastValidMWadjTimePlus6 = LastValidMWadjTime+0.25; 798 FirstHistoryCIValue = History.HistoryFile[XInc].CI; 799 FirstMWadjTime = HistoryRecTime; 800 FirstMWadjTimePlus12hr = HistoryRecTime+0.5; 801 break; 802 case 31: 803 History.HistoryFile[XInc].rule8 = 32; 804 if(Env.DEBUG==100) { 805 System.out.printf("rule8 was 31 current is 32\n"); 806 } 807 if(HistoryRecTime<=FirstMWadjTimePlus12hr) { 808 /* merge forward to 4.8 for first 12 hours*/ 809 InterpTimePart = 1.0-((FirstMWadjTimePlus12hr-HistoryRecTime)/ 810 (FirstMWadjTimePlus12hr-FirstMWadjTime)); 811 IntensityCIMergeValue = MWIntensityTnoValue1a; 812 NewIntensityEstScore = ((IntensityCIMergeValue-FirstHistoryCIValue)*InterpTimePart)+FirstHistoryCIValue; 813 if(Env.DEBUG==100) { 814 System.out.printf("InterpTimePart=%f IntensityCIMergeValue=%f NewIntensityEstScore=%f\n",InterpTimePart, 815 IntensityCIMergeValue,NewIntensityEstScore); 816 } 817 History.HistoryFile[XInc].Traw = NewIntensityEstScore; 818 History.HistoryFile[XInc].Tfinal = NewIntensityEstScore; 819 History.HistoryFile[XInc].CI = NewIntensityEstScore; 820 } 821 LastValidMWadjTime = HistoryRecTime; 822 LastValidMWadjTimePlus6 = LastValidMWadjTime+0.25; 823 break; 824 case 32: 825 History.HistoryFile[XInc].rule8 = 32; 826 if(Env.DEBUG==100) { 827 System.out.printf("rule8 was 32 current is 32\n"); 828 } 829 if(HistoryRecTime<=FirstMWadjTimePlus12hr) { 830 if(MWScoreInput>=MWScoreThresholdValue1) { 831 if(Env.DEBUG==100) { 832 System.out.printf("merge to 4.8\n"); 833 } 834 /* merge forward to 4.8, if necessary */ /* check to make sure MW score is not 5.0 */ 835 if(MWScoreInput<MWScoreThresholdValue2) { 836 InterpTimePart = 1.0-((FirstMWadjTimePlus12hr-HistoryRecTime)/ 837 (FirstMWadjTimePlus12hr-FirstMWadjTime)); 838 IntensityCIMergeValue = MWIntensityTnoValue1a; 839 NewIntensityEstScore = ((IntensityCIMergeValue-FirstHistoryCIValue)*InterpTimePart)+FirstHistoryCIValue; 840 if(Env.DEBUG==100) { 841 System.out.printf("InterpTimePart=%f IntensityCIMergeValue=%f NewIntensityEstScore=%f\n", 842 InterpTimePart,IntensityCIMergeValue,NewIntensityEstScore); 843 } 844 } else { 845 if(Env.DEBUG==100) { 846 System.out.printf("holding at 5.0\n"); 847 } 848 NewIntensityEstScore = MWIntensityTnoValue2; 849 } 850 History.HistoryFile[XInc].Traw = NewIntensityEstScore; 851 History.HistoryFile[XInc].Tfinal = NewIntensityEstScore; 852 History.HistoryFile[XInc].CI = NewIntensityEstScore; 853 LastValidMWCIValue = History.HistoryFile[XInc].CI; 854 LastValidMWadjTime = HistoryRecTime; 855 LastValidMWadjTimePlus6 = LastValidMWadjTime+0.25; 856 } else { 857 if(Env.DEBUG==100) { 858 System.out.printf("MW value less than 20... START hold\n"); 859 } 860 History.HistoryFile[XInc].rule8 = 33; 861 IntensityEstimateValueReturn = LastValidMWCIValue; 862 History.HistoryFile[XInc].Traw = LastValidMWCIValue; 863 History.HistoryFile[XInc].Tfinal = LastValidMWCIValue; 864 History.HistoryFile[XInc].CI = LastValidMWCIValue; 865 } 866 } else { 867 if(HistoryRecTime<=CurrentMWTimePlus12hr) { 868 if(MWScoreInput>=MWScoreThresholdValue1) { 869 if(Env.DEBUG==100) { 870 System.out.printf("rule8 was 32 keep as 32 (hold at last value of %f)\n",LastValidMWCIValue); 871 } 872 History.HistoryFile[XInc].Traw = LastValidMWCIValue; 873 History.HistoryFile[XInc].Tfinal = LastValidMWCIValue; 874 History.HistoryFile[XInc].CI = LastValidMWCIValue; 875 LastValidMWCIValue = History.HistoryFile[XInc].CI; 876 LastValidMWadjTime = HistoryRecTime; 877 LastValidMWadjTimePlus6 = LastValidMWadjTime+0.25; 878 } else { 879 if(Env.DEBUG==100) { 880 System.out.printf("MW value less than 20... hold\n"); 881 } 882 History.HistoryFile[XInc].rule8 = 33; 883 History.HistoryFile[XInc].Traw = LastValidMWCIValue; 884 History.HistoryFile[XInc].Tfinal = LastValidMWCIValue; 885 History.HistoryFile[XInc].CI = LastValidMWCIValue; 886 IntensityEstimateValueReturn = LastValidMWCIValue; 887 } 888 } else { 889 if(Env.DEBUG==100) { 890 System.out.printf("rule8 was 32 greater than 12 hours old... turn off!!!\n"); 891 } 892 History.HistoryFile[XInc].rule8 = 34; 893 History.HistoryFile[XInc].Traw = LastValidMWCIValue; 894 History.HistoryFile[XInc].Tfinal = LastValidMWCIValue; 895 History.HistoryFile[XInc].CI = LastValidMWCIValue; 896 MWScoreApplicationFlag = 0; 897 } 898 } 899 break; 900 case 33: 901 if(Env.DEBUG==100) { 902 System.out.printf("HistoryRecTime=%f LastValidMWadjTimeP6=%f\n", 903 HistoryRecTime,LastValidMWadjTimePlus6); 904 } 905 if(HistoryRecTime<=LastValidMWadjTimePlus6) { 906 if(MWScoreInput>=MWScoreThresholdValue1) { 907 if(Env.DEBUG==100) { 908 System.out.printf("rule8 was 33 mwscore>threshold1... turn back ON\n"); 909 } 910 History.HistoryFile[XInc].rule8 = 32; /* Turn back ON */ 911 LastValidMWadjTime = HistoryRecTime; 912 LastValidMWadjTimePlus6 = LastValidMWadjTime+0.25; 913 } else { 914 if(Env.DEBUG==100) { 915 System.out.printf("rule8 was 33 hold at 33\n"); 916 } 917 History.HistoryFile[XInc].rule8 = 33; /* hold */ 918 } 919 History.HistoryFile[XInc].Traw = LastValidMWCIValue; 920 History.HistoryFile[XInc].Tfinal = LastValidMWCIValue; 921 History.HistoryFile[XInc].CI = LastValidMWCIValue; 922 LastValidMWCIValue = History.HistoryFile[XInc].CI; 923 MWScoreApplicationFlag = 1; 924 } else { 925 if(Env.DEBUG==100) { 926 System.out.printf("rule8 was 33 GREATER THAN 6 hours old! TURNING OFF\n"); 927 } 928 History.HistoryFile[XInc].rule8 = 34; /* turn off */ 929 CommentString = ""; 930 CommentString = String.format("MW OFF HOLD >=6hrs old"); 931 History.HistoryFile[XInc].comment = CommentString; 932 MWScoreApplicationFlag = 0; 933 } 934 break; 935 case 34: 936 /* added */ 937 if(MWScoreInput>=MWScoreThresholdValue1) { 938 if(Env.DEBUG==100) { 939 System.out.printf("rule8 was 34 mwscore>threshold1... turn back ON\n"); 940 } 941 History.HistoryFile[XInc].rule8 = 31; 942 LastValidMWadjTime = HistoryRecTime; 943 LastValidMWadjTimePlus6 = LastValidMWadjTime+0.25; 944 History.HistoryFile[XInc].Traw = LastValidMWCIValue; 945 History.HistoryFile[XInc].Tfinal = LastValidMWCIValue; 946 History.HistoryFile[XInc].CI = LastValidMWCIValue; 947 LastValidMWCIValue = History.HistoryFile[XInc].CI; 948 MWScoreApplicationFlag = 1; 949 CommentString = ""; 950 History.HistoryFile[XInc].comment = CommentString; 951 } else { 952 if(Env.DEBUG==100) { 953 System.out.printf("rule8 was 34 adjustment is off!\n"); 954 } 955 MWScoreApplicationFlag = 0; 956 } 957 /* end added */ 958 break; 959 default: 960 if(Env.DEBUG==100) { 961 System.out.printf("DEFAULT : MW OFF at time %f\n",HistoryRecTime); 962 } 963 } 964 System.out.printf("resetting MWdate/time for record XINC=%d\n",XInc); 965 History.HistoryFile[XInc].mwscore = MWScoreInput; 966 History.HistoryFile[XInc].mwdate = Env.MWJulianDate; 967 History.HistoryFile[XInc].mwtime = Env.MWHHMMSSTime; 968 } 969 LastRule8Flag = History.HistoryFile[XInc].rule8; 970 PreviousMWScoreValue = History.HistoryFile[XInc].mwscore; 971 } 972 XInc++; 973 } 974 /* deal with last/current record */ 975 } 976 977 /*deal with last/current record */ 978 if(Env.DEBUG==100) { 979 System.out.printf("CURRENT RECORD IS LAST\n"); 980 } 981 /* first record after MW time is current record... 982 * mark it with appropriate Rule 8 value 983 */ 984 if(Env.DEBUG==100) { 985 System.out.printf("LastRule8Flag=%d\n",LastRule8Flag); 986 } 987 switch (LastRule8Flag) { 988 case 30: 989 History.IRCurrentRecord.rule8 = 31; 990 if(Env.DEBUG==100) { 991 System.out.printf("rule8 was 30 current is 31\n"); 992 System.out.printf("LastValidMWCIValue=%f\n",LastValidMWCIValue); 993 } 994 IntensityEstimateValueReturn = Math.max(LastValidMWCIValue,MWIntensityTnoValue1); 995 MWScoreApplicationFlag = 1; 996 break; 997 case 31: 998 History.IRCurrentRecord.rule8 = 32; 999 if(Env.DEBUG==100) { 1000 System.out.printf("rule8 was 31 current is 32\n"); 1001 System.out.printf("LastValidMWCIValue=%f\n",LastValidMWCIValue); 1002 } 1003 IntensityEstimateValueReturn = Math.max(LastValidMWCIValue,MWIntensityTnoValue1); 1004 MWScoreApplicationFlag = 1; 1005 break; 1006 case 32: 1007 History.IRCurrentRecord.rule8 = 32; 1008 if(Env.DEBUG==100) { 1009 System.out.printf("rule8 was 32 current is 32\n"); 1010 } 1011 MWScoreApplicationFlag = 1; 1012 /* check for change in MW value from previous record */ 1013 double MWScoreDiffValue = Math.abs(PreviousMWScoreValue-MWScoreInput); 1014 if(Env.DEBUG==100) { 1015 System.out.printf("previousMWvalue=%f currentMWvalue=%f diff=%f\n", 1016 PreviousMWScoreValue,MWScoreInput,MWScoreDiffValue); 1017 } 1018 if(MWScoreInput>=MWScoreThresholdValue1) { 1019 if(Env.DEBUG==100) { 1020 System.out.printf("currentTime=%f MWTimeplus12=%f\n",CurrentTime,FirstMWadjTimePlus12hr); 1021 } 1022 if(CurrentTime<=FirstMWadjTimePlus12hr) { 1023 if(MWScoreInput<MWScoreThresholdValue2) { 1024 if(Env.DEBUG==100) { 1025 System.out.printf("merging to 4.8\n"); 1026 } 1027 InterpTimePart = 1.0-((FirstMWadjTimePlus12hr-CurrentTime)/ 1028 (FirstMWadjTimePlus12hr-FirstMWadjTime)); 1029 IntensityCIMergeValue = MWIntensityTnoValue1a; 1030 NewIntensityEstScore = ((IntensityCIMergeValue-FirstHistoryCIValue)*InterpTimePart)+FirstHistoryCIValue; 1031 if(Env.DEBUG==100) { 1032 System.out.printf("InterpTimePart=%f IntensityCIMergeValue=%f NewIntensityEstScore=%f\n", 1033 InterpTimePart,IntensityCIMergeValue,NewIntensityEstScore); 1034 } 1035 } else { 1036 if(Env.DEBUG==100) { 1037 System.out.printf("holding at 5.0\n"); 1038 } 1039 NewIntensityEstScore = MWIntensityTnoValue2; 1040 } 1041 IntensityEstimateValueReturn = NewIntensityEstScore; 1042 } else { 1043 if(Env.DEBUG==100) { 1044 System.out.printf("CurrentTime=%f CurrentMWTimePlus12hr=%f\n",CurrentTime,CurrentMWTimePlus12hr); 1045 } 1046 if(CurrentTime<=CurrentMWTimePlus12hr) { 1047 if(Env.DEBUG==100) { 1048 System.out.printf("***rule8 was 32 keep as 32 (hold at last value of %f)\n",LastValidMWCIValue); 1049 } 1050 IntensityEstimateValueReturn = LastValidMWCIValue; 1051 } else { 1052 CommentString = ""; 1053 CommentString = String.format("MW OFF >=12hrs old"); 1054 History.IRCurrentRecord.comment = CommentString; 1055 if(Env.DEBUG==100) { 1056 System.out.printf("rule8 was 33 GREATER THAN 12 hours old! TURNING OFF\n"); 1057 } 1058 History.IRCurrentRecord.rule8 = 34; /* turn off */ 1059 IntensityEstimateValueReturn = LastValidMWCIValue; 1060 MWScoreApplicationFlag = 0; 1061 } 1062 } 1063 } else { 1064 if(Env.DEBUG==100) { 1065 System.out.printf("MW value < 20: rule8 was 32 current is 33 STARTING HOLD\n"); 1066 } 1067 History.IRCurrentRecord.rule8 = 33; /* start hold for 12 hrs */ 1068 IntensityEstimateValueReturn = LastValidMWCIValue; 1069 } 1070 break; 1071 case 33: 1072 if(Env.DEBUG==100) { 1073 System.out.printf("CurrentTime=%f CurrentMWTimePlus6hr=%f\n",CurrentTime,CurrentMWTimePlus6hr); 1074 } 1075 if(CurrentTime<=CurrentMWTimePlus6hr) { 1076 if(MWScoreInput>=MWScoreThresholdValue1) { 1077 if(Env.DEBUG==100) { 1078 System.out.printf("rule8 was 33 current is 32 score >threshold1\n"); 1079 } 1080 History.IRCurrentRecord.rule8 = 32; /* turn back ON */ 1081 } else { 1082 if(Env.DEBUG==100) { 1083 System.out.printf("rule8 was 33 current is 33 STILL HOLDING\n"); 1084 } 1085 History.IRCurrentRecord.rule8 = 33; /* start hold for 12 hrs */ 1086 } 1087 IntensityEstimateValueReturn = LastValidMWCIValue; 1088 MWScoreApplicationFlag = 1; 1089 } else { 1090 CommentString = ""; 1091 CommentString = String.format("MW OFF HOLD >=6hrs old"); 1092 History.IRCurrentRecord.comment = CommentString; 1093 if(Env.DEBUG==100) { 1094 System.out.printf("rule8 was 33 GREATER THAN 6 hours old! TURNING OFF\n"); 1095 } 1096 History.IRCurrentRecord.rule8 = 34; /* turn off */ 1097 IntensityEstimateValueReturn = LastValidMWCIValue; 1098 MWScoreApplicationFlag = 0; 1099 } 1100 break; 1101 /* added */ 1102 case 34: 1103 if(MWScoreInput>=MWScoreThresholdValue1) { 1104 if(Env.DEBUG==100) { 1105 System.out.printf("rule8 was 34 current is 31 score >threshold1\n"); 1106 } 1107 History.IRCurrentRecord.rule8 = 31; /* turn back ON */ 1108 IntensityEstimateValueReturn = LastValidMWCIValue; 1109 MWScoreApplicationFlag = 1; 1110 } else { 1111 IntensityEstimateValueReturn = InputIntensityEstStore; 1112 MWScoreApplicationFlag = 0; 1113 } 1114 break; 1115 /* end added */ 1116 default: 1117 IntensityEstimateValueReturn = InputIntensityEstStore; 1118 MWScoreApplicationFlag = 0; 1119 if(Env.DEBUG==100) { 1120 System.out.printf("default!\n"); 1121 } 1122 } 1123 if(Env.DEBUG==100) { 1124 System.out.printf("Setting current MW score to %f\n",MWScoreInput); 1125 } 1126 History.IRCurrentRecord.mwscore = Env.MWScore; 1127 History.IRCurrentRecord.mwdate = Env.MWJulianDate; 1128 History.IRCurrentRecord.mwtime = Env.MWHHMMSSTime; 1129 IntensityEstimateValueReturn = ((double)(int)((IntensityEstimateValueReturn+0.05)*10.0))/10.0; 1130 /* EXIT_Routine */ 1131 } else { 1132 /* need to put the intensity score into the correct place in the history file */ 1133 XInc = 0; 1134 while(XInc<NumRecsHistory) { 1135 RecDate = History.HistoryFile[XInc].date; 1136 RecTime = History.HistoryFile[XInc].time; 1137 HistoryRecTime = Functions.calctime(RecDate,RecTime); 1138 if(HistoryRecTime>=CurrentMWTime) { 1139 /* determine if there is a record after MW time */ 1140 if(Env.DEBUG==100) { 1141 System.out.printf("putting MW value of %f into history file at %f!\n",MWScoreInput,HistoryRecTime); 1142 } 1143 History.HistoryFile[XInc].mwscore = MWScoreInput; 1144 History.HistoryFile[XInc].mwdate = Env.MWJulianDate; 1145 History.HistoryFile[XInc].mwtime = Env.MWHHMMSSTime; 1146 } 1147 XInc++; 1148 } 1149 } 1150 1151 /* IntensityEstimateValueReturn = IntensityEstimateValueReturn; compiler says this does nothing */ 1152 if(Env.DEBUG==100) { 1153 System.out.printf("exit *IntensityEstimateValue_Return=%f\n",IntensityEstimateValueReturn); 1154 System.out.printf("MWScoreApplicationFlag=%d\n",MWScoreApplicationFlag); 1155 } 1156 1157 return new double[] { (double)MWScoreApplicationFlag, IntensityEstimateValueReturn }; 1158 } 1159 1160}