Giter Club home page Giter Club logo

Comments (11)

WesleyDAN avatar WesleyDAN commented on May 25, 2024 1

Many thanks for your timely reply.

  1. Yes, it will work when using 'azimuth[lat.values <= 0] = 0', instead of 'azimuth[azimuth <= 0] = 0'
  2. I am afraid (e.g.) 'slope[below_25] = 0.87 * lat.values[below_25]' will still return negative values/slopes. The equation for calculating optimal panel slope only works correctly when positive value is fed according to the reference.
    'lat.values = np.abs(lat.values)' before 'below_25 = np.abs(lat.values) <= np.deg2rad(25)' should be added, right?

from atlite.

WesleyDAN avatar WesleyDAN commented on May 25, 2024 1

Many thanks. Yes, it will work correctly now.

from atlite.

euronion avatar euronion commented on May 25, 2024

You are referring to these lines, right?

def latitude_optimal(lon, lat, solar_position):
if (lat < 0).any():
raise NotImplementedError('Not implemented for negative latitudes')
slope = np.empty_like(lat.values)
below_25 = lat.values <= np.deg2rad(25)
below_50 = lat.values <= np.deg2rad(50)
slope[below_25] = 0.87 * lat.values[below_25]
slope[~below_25 & below_50] = 0.76 * lat.values[~below_25 & below_50] + np.deg2rad(0.31)
slope[~below_50] = np.deg2rad(40.)
return dict(slope=xr.DataArray(slope, coords=lat.coords), azimuth=180.)

Changed to

below_25 = np.abs(lat.values) <= np.deg2rad(25) 
below_50 = np.abs(lat.values) <= np.deg2rad(50) 

should work, the simple approach applied there does in its original form not distinguish between northern and southern hemisphere.

But that's also exactly what makes me wary and a bit reluctant to change it:
Maybe there is some good reason for this limitation (but maybe the assert is obsolete).

@coroa Did you write that part of the code and remember why the limitation was put into place?

from atlite.

WesleyDAN avatar WesleyDAN commented on May 25, 2024

Exactly, but I am not sure whether 'azimuth=180.' should be changed to 'azimuth=0.' . because it is explained that 'azimuth = 180 faces exactly South' at the beginning in 'orientation.py'.

from atlite.

euronion avatar euronion commented on May 25, 2024

Yep, that has to be addressed as well.

Can you checkout the branch optimal-orientation-globally and see whether this works for you and produces expected results?

from atlite.

WesleyDAN avatar WesleyDAN commented on May 25, 2024

Thanks, it's difficult to check out whether the result is correct.
But I am not sure 'azimuth = np.empty_like(lat.values)' will create expected array according to the sign of value (it creates random value, eg create -5 for latitude 20 instead of 5)
Also, it seems 'abs' is not applied to negative latitude, in which case, the equation produce incorrect panel slopes.

I replace 'azimuth = np.empty_like(lat.values) with 'lat_copy = np.copy(lat.values),
azimuth = (lat_copy>0)-0.5',
and add 'lat = abs(lat)' before 'below_25 … '

Does it make sense please?

from atlite.

euronion avatar euronion commented on May 25, 2024

I think I get what you mean. ;-)

Doing multiple things simultaneously I forgot to incoporate the np.abs(...).
The initial values in the azimuth variable are just placeholders and we need it as an empty shell. Masking is done with the original latitude values.

It should work now with the changes in the new branch. I tested it locally with reasonable results.

It would be great if you can test it for yourself and see if the results are reasonable!
Afterwards we can incorporate it into the productive code.

If you do not know how, then one method is to download the repository and checkout the new branch.
Using the console:

git clone https://github.com/PyPSA/atlite
git checkout remotes/origin/optimal-orientation-globally

Create a new environment for the test with the required packages, e.g.:

conda create --name atlite-test
conda activate atlite-test
conda env update -f atlite/atlite/environment.yaml

and install the branch as a package

pip install -e atlite/

Finally you need to edit the atlite/atlite/config.py file to point to the correct folder for your existing cutouts.
(as you originally did after the installation)

You should then be able to run your script as you are used to.

from atlite.

euronion avatar euronion commented on May 25, 2024

Thanks attentive!
The slope calculation is now always positive (as you correctly pointed out it should be):

slope[below_25] = 0.87 * np.abs(lat.values[below_25])
slope[~below_25 & below_50] = 0.76 * np.abs(lat.values[~below_25 & below_50]) + np.deg2rad(0.31)
slope[~below_50] = np.deg2rad(40.)

Changing lat.values = np.abs(lat.values) would change the original lat object (call-by-reference/function call with a mutuable argument). So that's not an option.

from atlite.

euronion avatar euronion commented on May 25, 2024

Can you test the branch locally (as I described above)? It would be helpful to have a positive test before incoporating it into the main code.

from atlite.

WesleyDAN avatar WesleyDAN commented on May 25, 2024

Yes, no problem. I will check out whether it produces the same results with my current codes.

from atlite.

WesleyDAN avatar WesleyDAN commented on May 25, 2024

Hi, sorry for the delay. In order to test, I created a new enviroment and installed 'git', 'pip', then I follow the steps as you provied.

It seems I cannot clone using 'git clone https://github.com/PyPSA/atlite', always shown 'RPC failed; curl 18 transfer closed with outstanding read data remaining' or 'fatal: destination path atlite already existes and is not an empty diretory'. I'm afraid it is the problem of my laptop's configuration or sth else, not the code. Btw, it was a tough work as well when I installed the existing current 'atlite', so it is the least option for me to re-install or update it honestly.

Fortunately, waht we wanna do mostly is to check part of the code in 'orientation.py' for converting at sites with negative latitude. I have applied the code for dozens of sites in the southern hemisphere, and the code can always produce reasonable results.

from atlite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.