Credit NASA POWER as it asks, and say how the data was changed

- The calculator gains a "Data attribution" link under the location with
  NASA POWER's requested acknowledgment, the data reference (Climatology API
  v2.10.0, downloaded 2026/10/04), the CC BY 4.0 license, and how WROLPi
  modified the data (rounded to one byte per value, temperature averaged
  into 1 degree cells, interpolated between cells), which CC BY 4.0 requires.
- The build script writes the same text to solar-climatology.LICENSE.txt
  beside the data, with the API version taken from NASA's responses and the
  date the tiles were downloaded.  A test keeps the page and file in step.
- Bumps wrolpi-help for the updated attribution in the help page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Roland 2026-10-04 18:13:07 -06:00
parent 49f2710b83
commit 58842db248
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
7 changed files with 133 additions and 6 deletions

View file

@ -0,0 +1,11 @@
Solar climatology for the WROLPi Solar calculator
Source: NASA POWER, https://power.larc.nasa.gov/
Data: 2001-2020 monthly climatology of ALLSKY_SFC_SW_DWN, ALLSKY_SFC_SW_DIFF, ALLSKY_SRF_ALB, T2M, on a 1° grid.
The data was obtained from the POWER Project's POWER Climatology API v2.10.0 version on 2026/10/04.
The data was obtained from National Aeronautics and Space Administration (NASA) Langley Research Center's Prediction Of Worldwide Energy Resources (POWER) project funded through the NASA Earth Science Division.
License: Creative Commons Attribution 4.0 International (CC BY 4.0), https://creativecommons.org/licenses/by/4.0/
Changes: WROLPi modified the data: values are rounded to fit one byte each (0.04 kWh/m²/day for irradiance, 0.004 for albedo, 0.5 °C for temperature), temperatures are averaged from NASA's 0.5° x 0.625° grid into 1° cells, and the calculator interpolates between cells.

View file

@ -2,6 +2,7 @@ import React from "react";
import {useSearchParams} from "react-router";
import {
Accordion,
Anchor,
Button,
Grid,
Group,
@ -36,7 +37,15 @@ import {
totalLoss,
TRACKING,
} from "./solar";
import {CLIMATOLOGY_SOURCE, lookupClimatology, useClimatology} from "./solarData";
import {
CLIMATOLOGY_ACKNOWLEDGMENT,
CLIMATOLOGY_CHANGES,
CLIMATOLOGY_DATA_REFERENCE,
CLIMATOLOGY_LICENSE,
CLIMATOLOGY_SOURCE,
lookupClimatology,
useClimatology,
} from "./solarData";
import {SolarOffGrid} from "./SolarOffGrid";
// Every input lives in the URL query so the Share button (which shares window.location.href) shares
@ -207,6 +216,7 @@ const GEOLOCATION_ERRORS = {
function LocationSection({get, set, s, climatology}) {
const [locating, setLocating] = React.useState(false);
const [showAttribution, setShowAttribution] = React.useState(false);
const [geoError, setGeoError] = React.useState(null);
const latError = get('lat') && s.latitude === null ? 'Latitude must be between -90 and 90' : null;
const lonError = get('lon') && s.longitude === null ? 'Longitude must be between -180 and 180' : null;
@ -238,7 +248,17 @@ function LocationSection({get, set, s, climatology}) {
Enter your own monthly sunlight under "Use my own sunlight data" below.
</Message>;
} else {
source = `Sunlight and temperature: ${CLIMATOLOGY_SOURCE}.`;
source = <>
Sunlight and temperature: {CLIMATOLOGY_SOURCE}.{' '}
<Anchor component='button' type='button' size='sm' onClick={() => setShowAttribution(!showAttribution)}>
Data attribution
</Anchor>
{showAttribution && <div style={{marginTop: '0.5em'}}>
<p>{CLIMATOLOGY_ACKNOWLEDGMENT} {CLIMATOLOGY_DATA_REFERENCE}</p>
<p>License: {CLIMATOLOGY_LICENSE}</p>
<p>{CLIMATOLOGY_CHANGES}</p>
</div>}
</>;
}
return <>

View file

@ -122,6 +122,16 @@ describe('SolarCalculator', () => {
expect(global.fetch).toHaveBeenCalledWith(expect.stringMatching(/\/data\/solar-climatology\.bin$/));
});
test('the data attribution expands', async () => {
renderWithProviders(<SolarCalculator/>, {route: DENVER});
await findEstimate();
expect(screen.queryByText(/Prediction Of Worldwide Energy Resources/)).not.toBeInTheDocument();
fireEvent.click(screen.getByRole('button', {name: 'Data attribution'}));
expect(screen.getByText(/Prediction Of Worldwide Energy Resources/)).toBeInTheDocument();
expect(screen.getByText(/WROLPi modified the data/)).toBeInTheDocument();
expect(screen.getByText(/CC BY 4\.0/, {selector: 'p'})).toBeInTheDocument();
});
test('typing writes the URL and leaves defaults out', async () => {
renderWithProviders(<SolarCalculator/>, {route: BASE});
fireEvent.change(screen.getByLabelText('Latitude'), {target: {value: '40°0\'54"N'}});

View file

@ -7,6 +7,20 @@ import React from "react";
export const CLIMATOLOGY_URL = `${process.env.PUBLIC_URL || ''}/data/solar-climatology.bin`;
export const CLIMATOLOGY_SOURCE = 'NASA POWER 2001–2020 monthly averages (CC BY 4.0)';
// Attribution, as NASA asks (https://power.larc.nasa.gov/docs/referencing/) and CC BY 4.0 requires. The
// build script writes the same text, with the API version and download date, to
// public/data/solar-climatology.LICENSE.txt; a test keeps the two in step.
export const CLIMATOLOGY_ACKNOWLEDGMENT = 'The data was obtained from National Aeronautics and Space '
+ 'Administration (NASA) Langley Research Center\'s Prediction Of Worldwide Energy Resources (POWER) project '
+ 'funded through the NASA Earth Science Division.';
export const CLIMATOLOGY_DATA_REFERENCE = 'The data was obtained from the POWER Project\'s POWER Climatology API '
+ 'v2.10.0 version on 2026/10/04.';
export const CLIMATOLOGY_LICENSE = 'Creative Commons Attribution 4.0 International (CC BY 4.0), '
+ 'https://creativecommons.org/licenses/by/4.0/';
export const CLIMATOLOGY_CHANGES = 'WROLPi modified the data: values are rounded to fit one byte each '
+ '(0.04 kWh/m²/day for irradiance, 0.004 for albedo, 0.5 °C for temperature), temperatures are averaged from '
+ 'NASA\'s 0.5° x 0.625° grid into 1° cells, and the calculator interpolates between cells.';
const MAGIC = 'WSOL';
const VERSION = 1;
const HEADER_BYTES = 8;

View file

@ -1,6 +1,13 @@
import fs from "fs";
import path from "path";
import {decodeClimatology, lookupClimatology} from "./solarData";
import {
CLIMATOLOGY_ACKNOWLEDGMENT,
CLIMATOLOGY_CHANGES,
CLIMATOLOGY_DATA_REFERENCE,
CLIMATOLOGY_LICENSE,
decodeClimatology,
lookupClimatology,
} from "./solarData";
import {estimateProduction} from "./solar";
import {encodeClimatology, uniformClimatology} from "./solarData.fixtures";
@ -139,3 +146,22 @@ describeReal('the built climatology file', () => {
expect(lookupClimatology(grid, 80, 15).ghi[11]).toBeLessThan(0.05);
});
});
describe('attribution', () => {
// The build script writes this notice beside the data; the page shows the same text.
const notice = fs.readFileSync(path.join(__dirname, '../../../public/data/solar-climatology.LICENSE.txt'), 'utf8');
test('the notice and the page credit NASA identically', () => {
expect(notice).toContain(CLIMATOLOGY_ACKNOWLEDGMENT);
expect(notice).toContain(CLIMATOLOGY_DATA_REFERENCE);
expect(notice).toContain(CLIMATOLOGY_LICENSE);
expect(notice).toContain(CLIMATOLOGY_CHANGES);
});
test('the acknowledgment is NASA POWER\'s requested wording', () => {
// https://power.larc.nasa.gov/docs/referencing/
expect(CLIMATOLOGY_ACKNOWLEDGMENT).toBe('The data was obtained from National Aeronautics and Space '
+ 'Administration (NASA) Langley Research Center\'s Prediction Of Worldwide Energy Resources (POWER) '
+ 'project funded through the NASA Earth Science Division.');
});
});

@ -1 +1 @@
Subproject commit 46f7843174b8e12cea5c5843437fd81d3289e148
Subproject commit 241ba0032e3b571f1919b2b4f1905449fbd567ed

View file

@ -11,7 +11,9 @@ when NASA publishes a new climatology period, so regenerating it should be rare.
Downloaded tiles are cached (see --cache), so an interrupted run resumes where it stopped.
NASA POWER data is licensed CC BY 4.0; the calculator credits it. https://power.larc.nasa.gov/
NASA POWER data is licensed CC BY 4.0. The build also writes solar-climatology.LICENSE.txt beside the
data, crediting NASA as it asks (https://power.larc.nasa.gov/docs/referencing/), with the API version,
the date the data was downloaded, and how WROLPi changed it.
File format (all integers little-endian), decoded by app/src/components/calculators/solarData.js:
@ -26,6 +28,7 @@ bands centered on -179.5 ... 179.5 (west to east). 255 means no data. Each par
round((value + offset) / step); see PARAMETERS.
"""
import argparse
import datetime
import json
import math
import pathlib
@ -49,6 +52,16 @@ ROWS, COLUMNS = 180, 360
MISSING = 255
VERSION = 1
# NASA's requested acknowledgment. Must match CLIMATOLOGY_ACKNOWLEDGMENT in solarData.js.
ACKNOWLEDGMENT = ('The data was obtained from National Aeronautics and Space Administration (NASA) Langley '
'Research Center\'s Prediction Of Worldwide Energy Resources (POWER) project funded through the '
'NASA Earth Science Division.')
LICENSE = 'Creative Commons Attribution 4.0 International (CC BY 4.0), https://creativecommons.org/licenses/by/4.0/'
# CC BY 4.0 requires saying what was changed. Must match CLIMATOLOGY_CHANGES in solarData.js.
CHANGES = ('WROLPi modified the data: values are rounded to fit one byte each (0.04 kWh/m²/day for irradiance, '
'0.004 for albedo, 0.5 °C for temperature), temperatures are averaged from NASA\'s 0.5° x 0.625° grid '
'into 1° cells, and the calculator interpolates between cells.')
# (NASA parameter, offset, step). Must match PARAMETERS in solarData.js, in the same order.
PARAMETERS = [
('ALLSKY_SFC_SW_DWN', 0, 0.04), # global horizontal, kWh/m²/day, 0-10.16
@ -71,13 +84,17 @@ def tile_url(parameter, lat_min, lon_min):
return f'{API}?{query}'
def tile_path(cache, parameter, lat_min, lon_min):
return cache / f'{parameter}_{lat_min}_{lon_min}.json'
def fetch_tile(parameter, lat_min, lon_min, cache, pause, retries=8):
"""Return the tile's GeoJSON, from the cache when possible.
NASA rate limits the API (HTTP 429); back off for up to 10 minutes rather than give up, since a
full build is about 2,600 requests.
"""
path = cache / f'{parameter}_{lat_min}_{lon_min}.json'
path = tile_path(cache, parameter, lat_min, lon_min)
if path.is_file():
return json.loads(path.read_text())
@ -117,6 +134,24 @@ def bin_points(points):
return {cell: [s / n if n else None for s, n in months] for cell, months in sums.items()}
def notice(api, accessed):
"""The attribution written beside the data. `api` is like "POWER Climatology API v2.10.0"."""
parameters = ', '.join(p for p, _, _ in PARAMETERS)
return (
'Solar climatology for the WROLPi Solar calculator\n'
'\n'
'Source: NASA POWER, https://power.larc.nasa.gov/\n'
f'Data: 2001-2020 monthly climatology of {parameters}, on a 1° grid.\n'
f'The data was obtained from the POWER Project\'s {api} version on {accessed:%Y/%m/%d}.\n'
'\n'
f'{ACKNOWLEDGMENT}\n'
'\n'
f'License: {LICENSE}\n'
'\n'
f'Changes: {CHANGES}\n'
)
def quantize(value, offset, step):
if value is None:
return MISSING
@ -134,6 +169,7 @@ def main():
tiles = [(lat, lon) for lat in range(-90, 90, TILE) for lon in range(-180, 180, TILE)]
out = bytearray(b'WSOL' + struct.pack('<BBH', VERSION, len(PARAMETERS), 0))
apis = set()
for parameter, offset, step in PARAMETERS:
print(f'{parameter}: {len(tiles)} tiles', flush=True)
@ -144,6 +180,8 @@ def main():
data = future.result()
header = data.get('header')
fill = header.get('fill_value', -999) if isinstance(header, dict) else -999
if isinstance(header, dict) and 'api' in header:
apis.add(f'{header["api"]["name"]} {header["api"]["version"]}')
for feature in data['features']:
lon, lat = feature['geometry']['coordinates'][:2]
monthly = feature['properties']['parameter'][parameter]
@ -165,6 +203,14 @@ def main():
args.output.write_bytes(out)
print(f'Wrote {args.output} ({len(out):,} bytes)')
# The access date is when the newest tile was downloaded, which a resumed build keeps honest.
newest = max(tile_path(args.cache, p, lat, lon).stat().st_mtime
for p, _, _ in PARAMETERS for lat, lon in tiles)
accessed = datetime.date.fromtimestamp(newest)
license_path = args.output.with_name(args.output.stem + '.LICENSE.txt')
license_path.write_text(notice(' / '.join(sorted(apis)), accessed), encoding='utf-8')
print(f'Wrote {license_path}')
if __name__ == '__main__':
main()