Skip to content

add more attributes to __repr__ methods #254

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 6 commits into from
Nov 4, 2016
Merged

Conversation

wholmgren
Copy link
Member

I've been wanting more attributes to be included in the string representations of objects. Here is a proposal, but I'm not sure if this is too verbose. This builds on #174.

In [1]: import pvlib

In [2]: location = pvlib.location.Location(32.2, -110.9, name='Tucson')

In [3]: location
Out[3]:
Location:
  name: Tucson
  latitude: 32.2
  longitude: -110.9
  altitude: 0
  tz: UTC

In [4]: system = pvlib.pvsystem.PVSystem()

In [5]: system
Out[5]:
PVSystem:
  surface_tilt: 0
  surface_azimuth: 180
  module: None
  inverter: None
  albedo: 0.25
  racking_model: open_rack_cell_glassback

In [6]: tracker = pvlib.tracking.SingleAxisTracker()

In [7]: tracker
Out[7]:
SingleAxisTracker:
  axis_tilt: 0
  axis_azimuth: 0
  max_angle: 90
  backtrack: True
  gcr: 0.2857142857142857
  surface_tilt: 0
  surface_azimuth: 180
  module: None
  inverter: None
  albedo: 0.25
  racking_model: open_rack_cell_glassback

In [8]: mc = pvlib.modelchain.ModelChain(
    system, location, dc_model='pvwatts', ac_model='pvwatts', spectral_model='no_loss', 
    losses_model='no_loss', aoi_model='physical')

In [9]: mc
Out[9]:
ModelChain:
  orientation_strategy: south_at_latitude_tilt
  clearsky_model: ineichen
  transposition_model: haydavies
  solar_position_method: nrel_numpy
  airmass_model: kastenyoung1989
  dc_model: pvwatts_dc
  ac_model: pvwatts_inverter
  aoi_model: physical_aoi_loss
  spectral_model: no_spectral_loss
  temp_model: sapm_temp
  losses_model: no_extra_losses

Thoughts? Too many attributes? newlines vs. commas?

@wholmgren wholmgren added this to the 0.4.2 milestone Oct 21, 2016
@jforbess
Copy link
Contributor

This is great. I like line breaks.

I think the only thing I am wondering how to improve is the notation for
losses_model, because there is no standard all-encompassing model for
system losses. Well, if there is one, it will likely be tweaked often. So I
guess I would expect to see a dict with loss names and loss values here
much of the time, rather than a loss_model_name. Is that supported?

On Thu, Oct 20, 2016 at 6:54 PM, Will Holmgren [email protected]
wrote:

I've been wanting more attributes to be included in the string
representations of objects. Here is a proposal, but I'm not sure if this is
too verbose. This builds on #174
#174.

In [1]: import pvlib

In [2]: location = pvlib.location.Location(32.2, -110.9, name='Tucson')

In [3]: location
Out[3]:
Location:
name: Tucson
latitude: 32.2
longitude: -110.9
altitude: 0
tz: UTC

In [4]: system = pvlib.pvsystem.PVSystem()

In [5]: system
Out[5]:
PVSystem:
surface_tilt: 0
surface_azimuth: 180
module: None
inverter: None
albedo: 0.25
racking_model: open_rack_cell_glassback

In [6]: tracker = pvlib.tracking.SingleAxisTracker()

In [7]: tracker
Out[7]:
SingleAxisTracker:
axis_tilt: 0
axis_azimuth: 0
max_angle: 90
backtrack: True
gcr: 0.2857142857142857
surface_tilt: 0
surface_azimuth: 180
module: None
inverter: None
albedo: 0.25
racking_model: open_rack_cell_glassback

In [8]: mc = pvlib.modelchain.ModelChain(
system, location, dc_model='pvwatts', ac_model='pvwatts', spectral_model='no_loss',
losses_model='no_loss', aoi_model='physical')

In [9]: mc
Out[9]:
ModelChain:
orientation_strategy: south_at_latitude_tilt
clearsky_model: ineichen
transposition_model: haydavies
solar_position_method: nrel_numpy
airmass_model: kastenyoung1989
dc_model: pvwatts_dc
ac_model: pvwatts_inverter
aoi_model: physical_aoi_loss
spectral_model: no_spectral_loss
temp_model: sapm_temp
losses_model: no_extra_losses

Thoughts? Too many attributes? newlines vs. commas?

You can view, comment on, or merge this pull request online at:

#254
Commit Summary

  • add more attributes to ModelChain repr
  • reprs for PVSystem and Location
  • add tracking repr

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#254, or mute the thread
https://github.com/notifications/unsubscribe-auth/AH66AaXYo0FA-RbXL0zs-g_6qa49b497ks5q2BtBgaJpZM4KcyHj
.

@adriesse
Copy link
Member

I think this kind of thing would be nice. More (all) objects could be
given a 'name' property to start. You could also consider a 'describe'
method.

On 2016-10-21 3:54, Will Holmgren wrote:

I've been wanting more attributes to be included in the string
representations of objects. Here is a proposal, but I'm not sure if
this is too verbose. This builds on #174
#174.

In [1]:import pvlib

In [2]: location= pvlib.location.Location(32.2,-110.9,name='Tucson')

In [3]: location
Out[3]:
Location:
name: Tucson
latitude:32.2
longitude:-110.9
altitude:0
tz:UTC

In [4]: system= pvlib.pvsystem.PVSystem()

In [5]: system
Out[5]:
PVSystem:
surface_tilt:0
surface_azimuth:180
module:None
inverter:None
albedo:0.25
racking_model: open_rack_cell_glassback

In [6]: tracker= pvlib.tracking.SingleAxisTracker()

In [7]: tracker
Out[7]:
SingleAxisTracker:
axis_tilt:0
axis_azimuth:0
max_angle:90
backtrack:True
gcr:0.2857142857142857
surface_tilt:0
surface_azimuth:180
module:None
inverter:None
albedo:0.25
racking_model: open_rack_cell_glassback

In [8]: mc= pvlib.modelchain.ModelChain(
system, location,dc_model='pvwatts',ac_model='pvwatts',spectral_model='no_loss',
losses_model='no_loss',aoi_model='physical')

In [9]: mc
Out[9]:
ModelChain:
orientation_strategy: south_at_latitude_tilt
clearsky_model: ineichen
transposition_model: haydavies
solar_position_method: nrel_numpy
airmass_model: kastenyoung1989
dc_model: pvwatts_dc
ac_model: pvwatts_inverter
aoi_model: physical_aoi_loss
spectral_model: no_spectral_loss
temp_model: sapm_temp
losses_model: no_extra_losses

Thoughts? Too many attributes? newlines vs. commas?


    You can view, comment on, or merge this pull request online at:

#254

    Commit Summary


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#254, or mute the thread
https://github.com/notifications/unsubscribe-auth/AIlYQ7IiEsSfBg9XrhzbCQaIic1xYy5Jks5q2BtCgaJpZM4KcyHj.

Photovoltaic Performance Labs Germany
Emmy-Noether-Str. 2
79110 Freiburg
Germany

+49-761-8973-5603 (Europe)
+49-174-532-7677 (Mobile)
+1-613-817-1652 (North America)

www.pvperformancelabs.com

@wholmgren
Copy link
Member Author

Thanks for the feedback @jforbess and @adriesse

@jforbess hmm, I agree that more losses information would be good, but I'm not sure that pvlib python is set up to use it this point. PVSystem and ModelChain currently only know how to apply the default pvwatts losses or no losses at all. If we at some point change PVSystem.pvwatts_losses to use a new losses attribute then we could add that to the PVSystem repr.

@adriesse sure, a name attribute sounds like a good idea for the rest of the classes. What would a describe method do differently?

@wholmgren
Copy link
Member Author

I'm going to go ahead and merge this. Of course, further discussion and improvements are welcome.

@wholmgren wholmgren merged commit df26efa into pvlib:master Nov 4, 2016
@wholmgren wholmgren deleted the repr branch September 9, 2017 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants