Skip to content

remove 0.8 deprecations from pvsystem.py, modelchain.py, rework temperature model param deprecation #1033

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 19 commits into from
Aug 27, 2020

Conversation

wholmgren
Copy link
Member

@wholmgren wholmgren commented Aug 25, 2020

I'm still struggling with the right approach for #1030. Here are examples of the behavior in this PR:

In [109]: PVSystem()
/Users/holmgren/git_repos/pvlib-python/pvlib/pvsystem.py:219: pvlibDeprecationWarning: temperature_model_parameters, racking_model, and module_type are not specified. Reverting to deprecated default: SAPM cell temperature model parameters for a glass/glass module in open racking. In v0.9 PVSystem.temperature_model_parameters will be empty dict unless set by temperature_model_parameters or valid combination of racking_model and module_type. Pass non-None value to any of these parameters to silence this warning.
  pvlibDeprecationWarning)
Out[109]:
PVSystem:
  name: None
  surface_tilt: 0
  surface_azimuth: 180
  module: None
  inverter: None
  albedo: 0.25
  racking_model: None
  module_type: None
  temperature_model_parameters: {'a': -3.47, 'b': -0.0594, 'deltaT': 3}

In [110]: PVSystem(racking_model=False)
Out[110]:
PVSystem:
  name: None
  surface_tilt: 0
  surface_azimuth: 180
  module: None
  inverter: None
  albedo: 0.25
  racking_model: False
  module_type: None
  temperature_model_parameters: {}

This change also causes 28 new warnings from just test_pvsystem.py. I'm sure there are more in test_modelchain.py. In practice, I think this only matters to users that call PVSystem.sapm_celltemp, so we could push the deprecation down to this method.

@wholmgren wholmgren added this to the 0.8.0 milestone Aug 26, 2020
@wholmgren wholmgren added the api label Aug 26, 2020
@wholmgren wholmgren changed the title remove 0.8 deprecations from pvsystem.py, rework temperature model param deprecation remove 0.8 deprecations from pvsystem.py, modelchain.py, rework temperature model param deprecation Aug 26, 2020
@wholmgren
Copy link
Member Author

Moving the deprecation warning from PVSystem.__init__ to PVSystem.sapm_celltemp works with one caveat: ModelChain.infer_temperature_method cannot infer the SAPM method. A temporary work around could be:

    def infer_temperature_model(self):
        params = set(self.system.temperature_model_parameters.keys())
        # revert this change in 0.9
        if set(['a', 'b', 'deltaT']) <= params or (if not params and self.system.racking_model is None and self.system.module_type is None):
            return self.sapm_temp  # system.sapm_celltemp will assign default keys and emit warning at runtime

Does that all seem reasonable @cwhanse?

Comment on lines 214 to 217
'in open racking. In v0.9 '
'PVSystem.temperature_model_parameters will be empty dict '
'unless set by temperature_model_parameters or valid '
'combination of racking_model and module_type. Pass non-None '
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
'in open racking. In v0.9 '
'PVSystem.temperature_model_parameters will be empty dict '
'unless set by temperature_model_parameters or valid '
'combination of racking_model and module_type. Pass non-None '
'in open racking. In v0.9, temperature_model_parameters or a valid '
'combination of racking_model and module_type will be required. '
' Pass non-None '

I'd prefer to be more specific how to use v0.9.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm ok with "will be required" if the warning is emitted from PVSystem.sapm_celltemp. I don't like it if the warning is emitted from the PVSystem.__init__ because it suggests a positional argument.

Copy link
Member

Choose a reason for hiding this comment

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

PVSystem() has always been a valid, non-warned statement. There's never been a requirement that PVSystem is a complete description of a system according to some model. We can discuss changing that, but it's inconsistent to require temperature parameters and nothing else.

Agree, and point taken. I'm OK with the change proposed for ModelChain.infer_temperature_model.

Copy link
Member Author

Choose a reason for hiding this comment

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

changed the text in the warning in the method

@cwhanse
Copy link
Member

cwhanse commented Aug 26, 2020

Moving the deprecation warning from PVSystem.__init__ to PVSystem.sapm_celltemp works with one caveat: ModelChain.infer_temperature_method cannot infer the SAPM method. A temporary work around could be:

I'm not following here - why move the warning from PVSystem.__init__ to sapm_celltemp? I think it works better to detect the None condition and apply the deprecated default when PVSystem is initialized, and let ModelChain assume that PVSystem has taken care of that.

@wholmgren
Copy link
Member Author

PVSystem() has always been a valid, non-warned statement. There's never been a requirement that PVSystem is a complete description of a system according to some model. We can discuss changing that, but it's inconsistent to require temperature parameters and nothing else.

@wholmgren
Copy link
Member Author

wholmgren commented Aug 26, 2020

I think this is now ready to merge.

Sorry for the churn as I worked out inconsistencies in flake8 settings between stickler and running locally. Added a flake8 section to setup.cfg so that running flake8 locally will use the same configuration as stickler. Added ignore statements for W503 and W504 (break before/after operator) to be consistent with current best practice.

The codecov/patch failure occurs because in the process of fighting flake8 I changed the name of a variable in a line that is apparently untested. I think it's a positive change overall so I recommend double checking the change in the review and overlooking the coverage failure. Or I can revert it.

Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
@kandersolar
Copy link
Member

FYI I noticed there's still an entry to sapm_aoi_loss in api.rst: https://pvlib-python.readthedocs.io/en/latest/api.html#sandia-array-performance-model-sapm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PVSystem.temperature_model_parameters requirement remove deprecated functions in 0.8
3 participants