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

@ -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.');
});
});