Skip to content

Commit

Permalink
Merge pull request #2031 from asfadmin/kim/displacement
Browse files Browse the repository at this point in the history
csv tweaks
  • Loading branch information
SpicyGarlicAlbacoreRoll authored Nov 22, 2024
2 parents 86a1a11 + b8f26d2 commit 746513b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</button>
<mat-menu #menu="matMenu">
<div class="chart-config-menu-panel">
<button mat-button (click)="onExportCSV()">{{'EXPORT' | translate}} {{ 'CSV' | translate }}</button>
<button mat-button (click)="onExportCSV()">{{'EXPORT' | translate}} CSV</button>
</div>
</mat-menu>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ export class TimeseriesChartComponent implements OnInit, OnDestroy {
});

if (result.state.checked) {
const series_key = `series ${result.state.seriesNumber}`
const series_key = result.state.seriesNumber.toString()
if (!!!this.exportableData[series_key]) {
this.exportableData[series_key] = []
}
Expand Down
9 changes: 8 additions & 1 deletion src/app/services/map/map.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import * as sceneStore from '@store/scenes';
import { HttpClient } from "@angular/common/http";

import * as polygonStyle from './polygon.style';
// import * as tileStyle from 'ol/style'
import * as views from './views';
import { SarviewsEvent } from '@models';
import { EventEmitter } from '@angular/core';
Expand Down Expand Up @@ -771,7 +772,13 @@ export class MapService {

this.displacementOverview = new TileLayer({
'source': overview_source,
'extent': response['extent']
'extent': response['extent'],
'style': {
// 'color': 'pink',
// 'fill': new Fill({
// 'color': 'red'
// })
}
});

this.map.addLayer(this.displacementOverview);
Expand Down
10 changes: 2 additions & 8 deletions src/app/services/netcdf-service.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class NetcdfService {
private descendingCache = {}
private totalKeys = [];
private maxCacheSize = 10;
private csvHeaders = 'series, longitude, latitude, date (mm/dd/yr), short wavelength displacement, source file'
private csvHeaders = 'name, geometry, date (mm/dd/yr), short wavelength displacement, source file'

constructor(
private http: HttpClient,
Expand Down Expand Up @@ -129,19 +129,13 @@ export class NetcdfService {
// series 1, 1.0, 2.0, 05/14/2020, 0.500, granule1.nc
// ...
public toCSV(seriesData: { [index:string]: {}[]}): string {
const reg = /-?\d*\.\d+|\d+/g
let output = `${this.csvHeaders}\n`
const sortedSeriesKeys = Object.keys(seriesData).sort((s1, s2) => s1 < s2 ? -1 : 1)
for (const seriesNumber of sortedSeriesKeys) {

let points = seriesData[seriesNumber][0]['wkt'].match(reg)
const lon = points[0]
const lat = points[1]

for (const timestep of seriesData[seriesNumber]) {
if (timestep !== 'aoi') {
let dateDisplay = ''
// const sample = data.data[timestep]
if (timestep !== 'mean') {

const d = new Date(timestep['date'])
Expand All @@ -158,7 +152,7 @@ export class NetcdfService {
}
dateDisplay = `${monthDisplay}/${dayDisplay}/${d.getUTCFullYear()}`
}
output += `${seriesNumber}, ${lon}, ${lat}, ${dateDisplay}, ${timestep['short_wavelength_displacement']}, ${timestep['fileName']}\n`
output += `Series ${seriesNumber}, ${timestep['wkt']}, ${dateDisplay}, ${timestep['short_wavelength_displacement']}, ${timestep['fileName']}\n`
}
}
}
Expand Down

0 comments on commit 746513b

Please sign in to comment.