Skip to content

Just making sure I'm not barking up the wrong tree ...  #137

@abooda1981

Description

@abooda1981

Hello all. I've received a lot of help from @mikofski and @adambgnr for which I'm very grateful. I will need to run this kind of calculation for roughly ~ 1 year worth of data, I just wanted to make sure this isn't some weird mistake on my part. My codes below should be more or less self explanatory, but I will also offer some commentary.

FWIW (and I don't think it changes much), I'm using Python in R through the reticulate package and just trying to limit the routines that are actually written in Python. The only reason I'll mention this is you might notice some indexes are strange (eg, 60 elements start with 1 and end with 60 and not 0 and 59).

Here's where I begin, it's a set of irradiances which have been attenuated for each cell in a 60-cell module. Expressed in W/m^2.

#In R
irradiances_shaded_ready_to_use[[100]][[1000]]
          [,1]     [,2]     [,3]     [,4]     [,5]     [,6]
 [1,] 213.9050 175.0628 199.4696 174.6492 187.5090 159.7476
 [2,] 215.7734 230.8677 180.7294 166.6885 168.1310 199.5440
 [3,] 229.3951 217.8146 195.3562 183.8101 155.5469 183.3035
 [4,] 209.5742 227.4405 226.7091 194.7483 198.0606 180.4816
 [5,] 227.2889 206.0805 217.0147 226.6177 177.0109 182.4648
 [6,] 223.5549 221.1798 227.0709 234.8297 201.6358 196.6677
 [7,] 293.7470 293.7470 293.7470 293.7470 293.7470 293.7470
 [8,] 293.7470 293.7470 293.7470 293.7470 293.7470 293.7470
 [9,] 293.7470 293.7470 293.7470 293.7470 293.7470 293.7470
[10,] 293.7470 293.7470 293.7470 293.7470 293.7470 293.7470

Next, two python scripts which I can call from R. The first takes a module and a set of shades, as above, and applies "setSuns" to the module using the shades. The second takes a shaded module and returns a list of currents for each cell.

#This is a python script 
#It takes the shades and feeds them into the module
def shade_the_module_3(module_input, shade_input):
    positions_input = create_cell_pos_df(module_input)
    positions_input_np = positions_input.to_numpy()
    module_input.setSuns(shade_input, positions_input_np)
    return module_input
	
#This second python script returns a list of currents per cell 
def moving_day_shaded_currents(shaded_module):
    moving_day_shaded_currents = []
    for c, cells in enumerate(shaded_module.pvcells):
        moving_day_shaded_currents.append(shaded_module.pvcells[c].Igen)
    return moving_day_shaded_currents 

And the next bit, in R, ties it all together and produces a vector which holds the current generated by each cell.

#Let's now feed the shades into the module and then create a vector of currents 
#This is in R
shaded_module_attempt = shade_the_module_3(hello_module, irradiances_shaded_ready_to_use[[100]][[100]]/1000)

#This is what the output looks like 
#Note that I turned down the "Suns" by a factor of 1000 since 1 Sun = 1 kW/m^2 (or so I assume)

lists_into_vectors(moving_day_shaded_currents(shaded_module_attempt))
 [1] 0.2554633 0.2622693 0.2845493 0.2850022 0.2404546 0.2856346 0.2973223 0.2704208 0.3186892 0.2593214
[11] 0.2775086 0.2617764 0.3432120 0.3058749 0.2701947 0.2773878 0.2477220 0.2855832 0.2741956 0.2759731
[21] 0.3025052 0.2575780 0.3093930 0.2761150 0.2929953 0.3463328 0.3004103 0.3396224 0.3242891 0.3061217
[31] 0.3315860 0.3103403 0.3213330 0.3280117 0.3198549 0.3456261 0.3002707 0.3145019 0.3347570 0.2652785
[41] 0.3070128 0.3 344090 0.3567242 0.3435092 0.2984866 0.3556262 0.2902348 0.3673566 0.3232607 0.3634075
[51] 0.3227195 0.3250759 0.3489095 0.3244169 0.3375843 0.3451603 0.3037446 0.2909852 0.3619698 0.3159507
>  

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions