8
8
9
9
from functools import partial
10
10
import warnings
11
- import pandas as pd
12
11
13
12
from pvlib import (atmosphere , clearsky , pvsystem , solarposition , temperature ,
14
13
tools )
@@ -412,13 +411,6 @@ def dc_model(self, model):
412
411
self ._dc_model = self .pvsyst
413
412
elif model == 'pvwatts' :
414
413
self ._dc_model = self .pvwatts_dc
415
- elif model == 'singlediode' :
416
- warnings .warn ('DC model keyword singlediode used for '
417
- 'ModelChain object. singlediode is '
418
- 'ambiguous, use desoto instead. singlediode '
419
- 'keyword will be removed in v0.7.0 and '
420
- 'later' , pvlibDeprecationWarning )
421
- self ._dc_model = self .desoto
422
414
else :
423
415
raise ValueError (model + ' is not a valid DC power model' )
424
416
else :
@@ -480,24 +472,6 @@ def cec(self):
480
472
def pvsyst (self ):
481
473
return self ._singlediode (self .system .calcparams_pvsyst )
482
474
483
- def singlediode (self ):
484
- """Deprecated"""
485
- (photocurrent , saturation_current , resistance_series ,
486
- resistance_shunt , nNsVth ) = (
487
- self .system .calcparams_desoto (self .effective_irradiance ,
488
- self .cell_temperature ))
489
-
490
- self .desoto = (photocurrent , saturation_current , resistance_series ,
491
- resistance_shunt , nNsVth )
492
-
493
- self .dc = self .system .singlediode (
494
- photocurrent , saturation_current , resistance_series ,
495
- resistance_shunt , nNsVth )
496
-
497
- self .dc = self .system .scale_voltage_current_power (self .dc ).fillna (0 )
498
-
499
- return self
500
-
501
475
def pvwatts_dc (self ):
502
476
self .dc = self .system .pvwatts_dc (self .effective_irradiance ,
503
477
self .cell_temperature )
@@ -746,7 +720,7 @@ def effective_irradiance_model(self):
746
720
fd * self .total_irrad ['poa_diffuse' ])
747
721
return self
748
722
749
- def complete_irradiance (self , times = None , weather = None ):
723
+ def complete_irradiance (self , weather , times = None ):
750
724
"""
751
725
Determine the missing irradiation columns. Only two of the
752
726
following data columns (dni, ghi, dhi) are needed to calculate
@@ -758,19 +732,21 @@ def complete_irradiance(self, times=None, weather=None):
758
732
759
733
Parameters
760
734
----------
761
- times : None or DatetimeIndex, default None
762
- Times at which to evaluate the model. Can be None if
763
- attribute `times` is already set.
764
- weather : None or pandas.DataFrame, default None
765
- Table with at least two columns containing one of the
766
- following data sets: dni, dhi, ghi. Can be None if attribute
767
- `weather` is already set.
735
+ weather : DataFrame
736
+ Column names must be ``'dni'``, ``'ghi'``, ``'dhi'``,
737
+ ``'wind_speed'``, ``'temp_air'``. All irradiance components
738
+ are required. Air temperature of 20 C and wind speed
739
+ of 0 m/s will be added to the DataFrame if not provided.
740
+ times : None, deprecated
741
+ Deprecated argument included for API compatibility, but not
742
+ used internally. The index of the weather DataFrame is used
743
+ for times.
768
744
769
745
Returns
770
746
-------
771
747
self
772
748
773
- Assigns attributes: times, weather
749
+ Assigns attributes: weather
774
750
775
751
Examples
776
752
--------
@@ -782,19 +758,23 @@ def complete_irradiance(self, times=None, weather=None):
782
758
783
759
>>> # my_weather containing 'dhi' and 'ghi'.
784
760
>>> mc = ModelChain(my_system, my_location) # doctest: +SKIP
785
- >>> mc.complete_irradiance(my_datetime, my_weather) # doctest: +SKIP
786
- >>> mc.run_model() # doctest: +SKIP
761
+ >>> mc.complete_irradiance(my_weather) # doctest: +SKIP
762
+ >>> mc.run_model(mc.weather ) # doctest: +SKIP
787
763
788
764
>>> # my_weather containing 'dhi', 'ghi' and 'dni'.
789
765
>>> mc = ModelChain(my_system, my_location) # doctest: +SKIP
790
- >>> mc.run_model(my_datetime, my_weather) # doctest: +SKIP
766
+ >>> mc.run_model(my_weather) # doctest: +SKIP
791
767
"""
792
- if weather is not None :
793
- self . weather = weather
768
+ self . weather = weather
769
+
794
770
if times is not None :
795
- self .times = times
771
+ warnings .warn ('times keyword argument is deprecated and will be '
772
+ 'removed in 0.8. The index of the weather DataFrame '
773
+ 'is used for times.' , pvlibDeprecationWarning )
774
+
796
775
self .solar_position = self .location .get_solarposition (
797
- self .times , method = self .solar_position_method )
776
+ self .weather .index , method = self .solar_position_method )
777
+
798
778
icolumns = set (self .weather .columns )
799
779
wrn_txt = ("This function is not safe at the moment.\n " +
800
780
"Results can be too high or negative.\n " +
@@ -803,7 +783,7 @@ def complete_irradiance(self, times=None, weather=None):
803
783
804
784
if {'ghi' , 'dhi' } <= icolumns and 'dni' not in icolumns :
805
785
clearsky = self .location .get_clearsky (
806
- times , solar_position = self .solar_position )
786
+ self . weather . index , solar_position = self .solar_position )
807
787
self .weather .loc [:, 'dni' ] = pvlib .irradiance .dni (
808
788
self .weather .loc [:, 'ghi' ], self .weather .loc [:, 'dhi' ],
809
789
self .solar_position .zenith ,
@@ -822,62 +802,54 @@ def complete_irradiance(self, times=None, weather=None):
822
802
823
803
return self
824
804
825
- def prepare_inputs (self , times = None , weather = None ):
805
+ def prepare_inputs (self , weather , times = None ):
826
806
"""
827
807
Prepare the solar position, irradiance, and weather inputs to
828
808
the model.
829
809
830
810
Parameters
831
811
----------
832
- times : None or DatetimeIndex, default None
833
- Times at which to evaluate the model. Can be None if
834
- attribute `times` is already set.
835
- weather : None or DataFrame, default None
836
- If ``None``, the weather attribute is used. Column names
837
- must be ``'dni'``, ``'ghi'``, ``'dhi'``, ``'wind_speed'``,
838
- ``'temp_air'``. All irradiance components are required.
839
- Assumes air temperature is 20 C and wind speed is 0 m/s if
840
- not provided .
812
+ weather : DataFrame
813
+ Column names must be ``'dni'``, ``'ghi'``, ``'dhi'``,
814
+ ``'wind_speed'``, ``'temp_air'``. All irradiance components
815
+ are required. Air temperature of 20 C and wind speed
816
+ of 0 m/s will be added to the DataFrame if not provided.
817
+ times : None, deprecated
818
+ Deprecated argument included for API compatibility, but not
819
+ used internally. The index of the weather DataFrame is used
820
+ for times .
841
821
842
822
Notes
843
823
-----
844
- Assigns attributes: ``times``, `` solar_position``, ``airmass``,
824
+ Assigns attributes: ``solar_position``, ``airmass``,
845
825
``total_irrad``, `aoi`
846
826
847
827
See also
848
828
--------
849
829
ModelChain.complete_irradiance
850
830
"""
851
- if weather is not None :
852
- self .weather = weather
853
- if self .weather is None :
854
- self .weather = pd .DataFrame (index = times )
831
+
832
+ if not {'ghi' , 'dni' , 'dhi' } <= set (weather .columns ):
833
+ raise ValueError (
834
+ "Uncompleted irradiance data set. Please check your input "
835
+ "data.\n Data set needs to have 'dni', 'dhi' and 'ghi'.\n "
836
+ "Detected data: {0}" .format (list (weather .columns )))
837
+
838
+ self .weather = weather
855
839
856
840
if times is not None :
857
- self .times = times
841
+ warnings .warn ('times keyword argument is deprecated and will be '
842
+ 'removed in 0.8. The index of the weather DataFrame '
843
+ 'is used for times.' , pvlibDeprecationWarning )
844
+
845
+ self .times = self .weather .index
858
846
859
847
self .solar_position = self .location .get_solarposition (
860
- self .times , method = self .solar_position_method )
848
+ self .weather . index , method = self .solar_position_method )
861
849
862
850
self .airmass = self .location .get_airmass (
863
851
solar_position = self .solar_position , model = self .airmass_model )
864
852
865
- if not any ([x in ['ghi' , 'dni' , 'dhi' ] for x in self .weather .columns ]):
866
- warnings .warn ('Clear sky assumption for no input irradiance is '
867
- 'deprecated and will be removed in v0.7.0. Use '
868
- 'location.get_clearsky instead' ,
869
- pvlibDeprecationWarning )
870
- self .weather [['ghi' , 'dni' , 'dhi' ]] = self .location .get_clearsky (
871
- self .solar_position .index , self .clearsky_model ,
872
- solar_position = self .solar_position ,
873
- airmass_absolute = self .airmass ['airmass_absolute' ])
874
-
875
- if not {'ghi' , 'dni' , 'dhi' } <= set (self .weather .columns ):
876
- raise ValueError (
877
- "Uncompleted irradiance data set. Please check your input "
878
- "data.\n Data set needs to have 'dni', 'dhi' and 'ghi'.\n "
879
- "Detected data: {0}" .format (list (self .weather .columns )))
880
-
881
853
# PVSystem.get_irradiance and SingleAxisTracker.get_irradiance
882
854
# and PVSystem.get_aoi and SingleAxisTracker.get_aoi
883
855
# have different method signatures. Use partial to handle
@@ -921,32 +893,36 @@ def prepare_inputs(self, times=None, weather=None):
921
893
self .weather ['temp_air' ] = 20
922
894
return self
923
895
924
- def run_model (self , times = None , weather = None ):
896
+ def run_model (self , weather , times = None ):
925
897
"""
926
898
Run the model.
927
899
928
900
Parameters
929
901
----------
930
- times : None or DatetimeIndex, default None
931
- Times at which to evaluate the model. Can be None if
932
- attribute `times` is already set.
933
- weather : None or DataFrame, default None
934
- If ``None``, the weather attribute is used. Column names
935
- must be ``'dni'``, ``'ghi'``, ``'dhi'``, ``'wind_speed'``,
936
- ``'temp_air'``. All irradiance components are required.
937
- Assumes air temperature is 20 C and wind speed is 0 m/s if
938
- not provided .
902
+ weather : DataFrame
903
+ Column names must be ``'dni'``, ``'ghi'``, ``'dhi'``,
904
+ ``'wind_speed'``, ``'temp_air'``. All irradiance components
905
+ are required. Air temperature of 20 C and wind speed
906
+ of 0 m/s will be added to the DataFrame if not provided.
907
+ times : None, deprecated
908
+ Deprecated argument included for API compatibility, but not
909
+ used internally. The index of the weather DataFrame is used
910
+ for times .
939
911
940
912
Returns
941
913
-------
942
914
self
943
915
944
- Assigns attributes: times, solar_position, airmass, irradiance,
916
+ Assigns attributes: solar_position, airmass, irradiance,
945
917
total_irrad, effective_irradiance, weather, cell_temperature, aoi,
946
918
aoi_modifier, spectral_modifier, dc, ac, losses.
947
919
"""
920
+ if times is not None :
921
+ warnings .warn ('times keyword argument is deprecated and will be '
922
+ 'removed in 0.8. The index of the weather DataFrame '
923
+ 'is used for times.' , pvlibDeprecationWarning )
948
924
949
- self .prepare_inputs (times , weather )
925
+ self .prepare_inputs (weather )
950
926
self .aoi_model ()
951
927
self .spectral_model ()
952
928
self .effective_irradiance_model ()
0 commit comments