Skip to content

PSM4 get_ functions: remove default values for year #2471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 6 additions & 18 deletions pvlib/iotools/psm4.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@


def get_nsrdb_psm4_aggregated(latitude, longitude, api_key, email,
year='2023', time_step=60,
year, time_step=60,
parameters=PARAMETERS, leap_day=True,
full_name=PVLIB_PYTHON,
affiliation=PVLIB_PYTHON,
Expand All @@ -96,7 +96,7 @@ def get_nsrdb_psm4_aggregated(latitude, longitude, api_key, email,
email : str
NREL API uses this to automatically communicate messages back
to the user only if necessary
year : str, default '2023'
year : int or str
PSM4 API parameter specifing year (e.g. ``2023``) to download. The
allowed values update periodically, so consult the NSRDB reference
below for the current set of options. Called ``names`` in NSRDB API.
Expand Down Expand Up @@ -173,9 +173,6 @@ def get_nsrdb_psm4_aggregated(latitude, longitude, api_key, email,
latitude = ('%8.4f' % latitude).strip()
# TODO: make format_WKT(object_type, *args) in tools.py

# convert to string to accomodate integer years being passed in
year = str(year)

# convert pvlib names in parameters to PSM4 convention
parameters = [REQUEST_VARIABLE_MAP.get(a, a) for a in parameters]

Expand Down Expand Up @@ -314,9 +311,6 @@ def get_nsrdb_psm4_tmy(latitude, longitude, api_key, email, year='tmy',
latitude = ('%8.4f' % latitude).strip()
# TODO: make format_WKT(object_type, *args) in tools.py

# convert to string to accomodate integer years being passed in
year = str(year)

Comment on lines -317 to -319
Copy link
Member

Choose a reason for hiding this comment

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

Why is this only removed for one of the functions? I see this is present for the other three functions as well.

I support the removal since this line doesn't seem to be necessary, but we should be consistent.

Copy link
Member Author

Choose a reason for hiding this comment

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

The inconsistency is because this is the TMY function, where year is always a string ("tmy", "tgy-2020"). The other three deal with calendar years.

Copy link
Member Author

Choose a reason for hiding this comment

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

On second thought, it's not needed in any of these functions anymore. It was a copy/paste from get_psm3, where the year input was inspected to determine the relevant API endpoint, and being a string facilitated that inspection. For PSM4 it serves no purpose since we have one function per endpoint here. All of them are now removed.

Copy link
Member

@AdamRJensen AdamRJensen Jun 5, 2025

Choose a reason for hiding this comment

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

Exactly! I just ran the tests locally with all the string conversion removed and tests are passing.

# convert pvlib names in parameters to PSM4 convention
parameters = [REQUEST_VARIABLE_MAP.get(a, a) for a in parameters]

Expand Down Expand Up @@ -354,7 +348,7 @@ def get_nsrdb_psm4_tmy(latitude, longitude, api_key, email, year='tmy',
return read_nsrdb_psm4(fbuf, map_variables)


def get_nsrdb_psm4_conus(latitude, longitude, api_key, email, year='2023',
def get_nsrdb_psm4_conus(latitude, longitude, api_key, email, year,
time_step=60, parameters=PARAMETERS, leap_day=True,
full_name=PVLIB_PYTHON, affiliation=PVLIB_PYTHON,
utc=False, map_variables=True, url=None, timeout=30):
Expand All @@ -376,7 +370,7 @@ def get_nsrdb_psm4_conus(latitude, longitude, api_key, email, year='2023',
email : str
NREL API uses this to automatically communicate messages back
to the user only if necessary
year : str, default '2023'
year : int or str
PSM4 API parameter specifing year (e.g. ``2023``) to download. The
allowed values update periodically, so consult the NSRDB reference
below for the current set of options. Called ``names`` in NSRDB API.
Expand Down Expand Up @@ -453,9 +447,6 @@ def get_nsrdb_psm4_conus(latitude, longitude, api_key, email, year='2023',
latitude = ('%8.4f' % latitude).strip()
# TODO: make format_WKT(object_type, *args) in tools.py

# convert to string to accomodate integer years being passed in
year = str(year)

# convert pvlib names in parameters to PSM4 convention
parameters = [REQUEST_VARIABLE_MAP.get(a, a) for a in parameters]

Expand Down Expand Up @@ -494,7 +485,7 @@ def get_nsrdb_psm4_conus(latitude, longitude, api_key, email, year='2023',


def get_nsrdb_psm4_full_disc(latitude, longitude, api_key, email,
year='2023', time_step=60,
year, time_step=60,
parameters=PARAMETERS, leap_day=True,
full_name=PVLIB_PYTHON,
affiliation=PVLIB_PYTHON, utc=False,
Expand All @@ -517,7 +508,7 @@ def get_nsrdb_psm4_full_disc(latitude, longitude, api_key, email,
email : str
NREL API uses this to automatically communicate messages back
to the user only if necessary
year : str, default '2023'
year : int or str
PSM4 API parameter specifing year (e.g. ``2023``) to download. The
allowed values update periodically, so consult the NSRDB reference
below for the current set of options. Called ``names`` in NSRDB API.
Expand Down Expand Up @@ -595,9 +586,6 @@ def get_nsrdb_psm4_full_disc(latitude, longitude, api_key, email,
latitude = ('%8.4f' % latitude).strip()
# TODO: make format_WKT(object_type, *args) in tools.py

# convert to string to accomodate integer years being passed in
year = str(year)

# convert pvlib names in parameters to PSM4 convention
parameters = [REQUEST_VARIABLE_MAP.get(a, a) for a in parameters]

Expand Down
Loading