Skip to content

Update nasa_power VARIABLE_MAP with additional parameters#2762

Open
karlhillx wants to merge 2 commits into
pvlib:mainfrom
karlhillx:update/nasa-power-variable-map
Open

Update nasa_power VARIABLE_MAP with additional parameters#2762
karlhillx wants to merge 2 commits into
pvlib:mainfrom
karlhillx:update/nasa-power-variable-map

Conversation

@karlhillx
Copy link
Copy Markdown

Adds the following entries to VARIABLE_MAP in pvlib/iotools/nasa_power.py:

NASA POWER parameter pvlib variable Description
T2MDEW dew_point Dew point temperature
T2MWET dew_frost_point Dew/frost point at 2 m
TQV precipitable_water Precipitable water
RH2M relative_humidity Relative humidity at 2 m

Closes #2731

@github-actions
Copy link
Copy Markdown

Hey @karlhillx! 🎉

Thanks for opening your first pull request! We appreciate your
contribution. Please ensure you have reviewed and understood the
contributing guidelines.

If AI is used for any portion of this PR, you must vet the content
for technical accuracy.

@karlhillx
Copy link
Copy Markdown
Author

Noted, confirmed, etc. The added entries (T2MDEW, T2MWET, TQV, RH2M) map directly to the NASA POWER API parameter names, with pvlib names chosen to match existing conventions in VARIABLE_MAP. I've vetted for accuracy

Comment thread pvlib/iotools/nasa_power.py Outdated
'T2M': 'temp_air',
'WS2M': 'wind_speed_2m',
'WS10M': 'wind_speed',
'T2MDEW': 'dew_point',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'T2MDEW': 'dew_point',
'T2MDEW': 'temp_dew',

Comment thread pvlib/iotools/nasa_power.py Outdated
'WS2M': 'wind_speed_2m',
'WS10M': 'wind_speed',
'T2MDEW': 'dew_point',
'T2MWET': 'dew_frost_point',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'T2MWET': 'dew_frost_point',

This isn't a standard pvlib term. A general recommendation is to see whether other iotools function maps a similar variable.

Comment thread pvlib/iotools/nasa_power.py Outdated
'WS10M': 'wind_speed',
'T2MDEW': 'dew_point',
'T2MWET': 'dew_frost_point',
'TQV': 'precipitable_water',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other pvlib iotools functions also convert the unit of this parameter. Do you know what unit this parameter is in, and if so, can you check if it matches the pvlib standard?

@AdamRJensen
Copy link
Copy Markdown
Member

@karlhillx Is there a reason that you didn't include the other parameters listed in #2731?

@karlhillx
Copy link
Copy Markdown
Author

Thanks for the feedback. You are right that dew_point and dew_frost_point are not pvlib standard names. After checking all the other iotools modules, merra2, era5, tmy, epw, psm4, srml, and solcast all map dew point to temp_dew in degrees C. pvlib has no wet_bulb or frost_point variable anywhere.

T2MDEW and T2MWET are the same physical measurement, temperature at 2m in degrees C, just different triggering thresholds. Mapping both to temp_dew is consistent with the rest of pvlib and keeps the units correct.

Updated push incoming with the full set of missing parameters.

@karlhillx
Copy link
Copy Markdown
Author

PS unit bug fix needed

NASA POWER returns PS in kPa for all communities (RE, SB, AG). Confirmed via live API call. pvlib.atmosphere.pres2alt expects Pa.

At sea level, PS returns 101.325 kPa. Without conversion, pres2alt computes ~84,000 m instead of 0 m. Any downstream pressure-dependent calc (airmass, cell temp models, etc.) will be catastrophically wrong.

Fix: add kPa to Pa conversion after column rename. Suggested patch:

if map_variables:
    df = df.rename(columns=VARIABLE_MAP)
    # PS is returned in kPa; convert to Pa for pvlib compatibility
    if 'pressure' in df.columns:
        df['pressure'] = df['pressure'] * 1000

Two minor improvements (optional):

  • Change CLRSKY_DIFF to CLRSKY_SFC_SW_DIFF for full canonical names
  • Keep ALLSKY_SRF_ALB alongside SRF_ALB to avoid backward compat break

Copy link
Copy Markdown
Member

@IoannisSifnaios IoannisSifnaios left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there has been some misunderstanding on the source of these parameter names. In #2731 this link is given, which I don't think it the official NASA one. I have been looking at this one that has different parameter names.

Comment thread pvlib/iotools/nasa_power.py Outdated
'T2MDEW': 'temp_dew',
'T2MWET': 'temp_dew',
'RH2M': 'relative_humidity',
'SRF_ALB': 'albedo',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'SRF_ALB' is not the correct parameter name. It should be 'ALLSKY_SRF_ALB'

Comment thread pvlib/iotools/nasa_power.py Outdated
Comment on lines +25 to +26
'T2MDEW': 'temp_dew',
'T2MWET': 'temp_dew',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't have two parameters with the same name. If you ask the function to get 'temp_dew' it returns an error. I suggest you only keep 'T2MDEW': 'temp_dew' (which is what other pvlib functions do) and maybe either not rename the 'T2WET' or give another name (e.g., temp_wet_bulb). @AdamRJensen can you maybe weigh in on this?

Comment thread pvlib/iotools/nasa_power.py Outdated
'WS10M': 'wind_speed',
'ALLSKY_SRF_ALB': 'albedo',
'ALLSKY_SFC_LW_DWN': 'longwave_down',
'ALLSKY_TOA_SW_DWN': 'ghi_extra',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function returns an error for this name. Maybe you meant to use 'TOA_SW_DWN'?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karlhillx Please make sure that you test that all the parameters actually work.

Comment thread pvlib/iotools/nasa_power.py Outdated
'ALLSKY_SRF_ALB': 'albedo',
'ALLSKY_SFC_LW_DWN': 'longwave_down',
'ALLSKY_TOA_SW_DWN': 'ghi_extra',
'CLRSKY_DIFF': 'dhi_clear',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, getting an error for this one. Maybe you meant: 'CLRSKY_SFC_SW_DIFF'?

Comment thread pvlib/iotools/nasa_power.py
@karlhillx karlhillx force-pushed the update/nasa-power-variable-map branch from 294d8d4 to 741c2a4 Compare May 30, 2026 17:09
- Added: ALLSKY_SFC_LW_DWN, ALLSKY_TOA_SW_DWN, CLRSKY_DIFF, PS,
  T2MDEW, T2MWET, RH2M, SRF_ALB, TQV
- Fix PS unit conversion: kPa to Pa for pvlib.atmosphere compatibility
- Fix parameter names: CLRSKY_DIFF -> CLRSKY_SFC_SW_DIFF,
  ALLSKY_TOA_SW_DWN -> TOA_SW_DWN, SRF_ALB -> ALLSKY_SRF_ALB
- Drop T2MWET (duplicate target name breaks pandas rename)
- Add TQV unit conversion: kg/m^2 to cm
- Add regression tests for all VARIABLE_MAP params and unit conversions
@karlhillx karlhillx force-pushed the update/nasa-power-variable-map branch from 741c2a4 to 60638bf Compare May 30, 2026 17:18
@karlhillx
Copy link
Copy Markdown
Author

Thanks for the catches. Dropped T2MWET, corrected CLRSKY_DIFFCLRSKY_SFC_SW_DIFF and ALLSKY_TOA_SW_DWNTOA_SW_DWN, restored ALLSKY_SRF_ALB from main. Added TQV kg/m²→cm conversion and 4 regression tests covering all params end-to-end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update nasa_power VARIABLE_MAP

3 participants