Skip to content

Update nasa_power VARIABLE_MAP with additional parameters#2762

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

Update nasa_power VARIABLE_MAP with additional parameters#2762
karlhillx wants to merge 3 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

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

2 participants