Skip to content

Commit

Permalink
Merge pull request #1769 from ORNL-AMO/weather-data-fixes
Browse files Browse the repository at this point in the history
Weather data fixes
  • Loading branch information
rmroot authored Dec 5, 2024
2 parents 57f24a8 + 2c0430a commit d501492
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
11 changes: 10 additions & 1 deletion src/app/shared/helper-pipes/degree-day-total.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,16 @@ export class DegreeDayTotalPipe implements PipeTransform {
});
return totalMinutes / 1440;
} else {
let weatherDataSelection: WeatherDataSelection = sumBy as WeatherDataSelection;
let weatherDataSelection: WeatherDataSelection;
if (sumBy == 'coolingDegreeDay') {
weatherDataSelection = 'CDD';
} else if (sumBy == 'heatingDegreeDay') {
weatherDataSelection = 'HDD';
} else if (sumBy == 'dryBulbTemp') {
weatherDataSelection = 'dryBulbTemp';
} else if (sumBy == 'relativeHumidity') {
weatherDataSelection = 'relativeHumidity';
}
return getDegreeDayAmount(values, weatherDataSelection);
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/app/shared/helper-services/backup-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,6 @@ export class BackupDataService {
}

async importAccountBackupFile(backupFile: BackupFile): Promise<IdbAccount> {

console.log(backupFile);

this.analyticsService.sendEvent('import_backup_file');
this.loadingService.setLoadingMessage('Adding Account...');
let accountGUIDs: { oldId: string, newId: string } = {
Expand Down Expand Up @@ -324,6 +321,7 @@ export class BackupDataService {
delete predictorData.id;
predictorData.guid = newGUID;
predictorData.accountId = accountGUIDs.newId;

Check failure

Code scanning / CodeQL

Insecure randomness High

This uses a cryptographically insecure random number generated at
Math.random()
in a security context.
predictorData.date = this.getImportDate(predictorData.date);
predictorData.facilityId = this.getNewId(predictorData.facilityId, facilityGUIDs);
predictorData.predictorId = this.getNewId(predictorData.predictorId, predictorGUIDs);
await firstValueFrom(this.predictorDataDbService.addWithObservable(predictorData));
Expand Down
10 changes: 0 additions & 10 deletions src/app/shared/helper-services/degree-days.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,22 +160,12 @@ export class DegreeDaysService {
let heatingDegreeDifference: number = 0;
let coolingDegreeDay: number = 0;
let coolingDegreeDifference: number = 0;
if (averageDryBulbTemp < baseHeatingTemperature) {
heatingDegreeDifference = baseHeatingTemperature - averageDryBulbTemp;
heatingDegreeDay = heatingDegreeDifference * portionOfDay;
}

let gapInData: boolean = false
let minutesBetween: number = this.getMinutesBetweenDates(previousDate, localClimatologicalDataMonth[i].DATE);
if (minutesBetween > 720) {
gapInData = true;
}
if (averageDryBulbTemp < baseHeatingTemperature || averageDryBulbTemp > baseCoolingTemperature) {

let heatingDegreeDay: number = 0;
let heatingDegreeDifference: number = 0;
let coolingDegreeDay: number = 0;
let coolingDegreeDifference: number = 0;
if (averageDryBulbTemp < baseHeatingTemperature) {
heatingDegreeDifference = baseHeatingTemperature - averageDryBulbTemp;
heatingDegreeDay = heatingDegreeDifference * portionOfDay;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
[weatherDataSelection]="weatherDataSelection"></app-monthly-station-table>
</div>
</div>
<div class="row" *ngIf="detailedDegreeDays != 'error'">
<div class="row" *ngIf="detailedDegreeDays == 'error'">
<div class="col-12">
<div class="alert alert-danger">
Error occured while calculating degree days.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
</th>
<th>

</th>
<th *ngIf="weatherDataSelection != 'relativeHumidity'">
{{detailedDegreeDays | degreeDayTotal: 'dryBulbTemp' | number:'1.0-1'}} &percnt;
</th>
<th *ngIf="weatherDataSelection == 'degreeDays' || weatherDataSelection == 'HDD'">
{{detailedDegreeDays | degreeDayTotal: 'heatingDegreeDay' | number}}
Expand All @@ -74,9 +77,6 @@
<th *ngIf="weatherDataSelection == 'relativeHumidity'">
{{detailedDegreeDays | degreeDayTotal: 'relativeHumidity' | number:'1.0-4'}} &percnt;
</th>
<th *ngIf="weatherDataSelection == 'dryBulbTemp'">
{{detailedDegreeDays | degreeDayTotal: 'dryBulbTemp' | number:'1.0-1'}} &percnt;
</th>
</tr>
</tfoot>
</table>
Expand Down

0 comments on commit d501492

Please sign in to comment.