nortikin / sverchok

Sverchok
http://nortikin.github.io/sverchok/
GNU General Public License v3.0
2.23k stars 232 forks source link

Insolation calculation #2091

Closed Durman closed 6 years ago

Durman commented 6 years ago

Here one can find all nodes that I did on this topic for SNL node: https://gist.github.com/22388494d23d6e00d06f173831fcb141

I want to create insolation calculation. I think it is easy goal with raycaster node that will do main work. As result we have to receive insolation time in calculation points. Main task is to create script that will give directions of the sun. They will be depend on the time and the place. I have found good code that solves the same problem: https://github.com/mourner/suncalc I think it can be easily rewritten on Python. Also I already have something to show on the picture below.))

insolation calculation

Durman commented 6 years ago

It's not certainly what I want to do but something like that. https://www.youtube.com/watch?v=OpnjfWLWJdE

zeffii commented 6 years ago

it definitely worth a dedicated node at some point, when we get more scene conscious :)

zeffii commented 6 years ago

cool video. yeah.. look extremely doable :)

Durman commented 6 years ago

My algorithm will determine how long sun is shining during a day in calculation point. Buildings can cast shadows on the point and in this case insolation time will be less. It depends on height and width of opposite building. It is important to have such calculation when one going to build housing in Russia. In the video is another calculation it is not good example. I suppose that there is not such calculation in another countries.

zeffii commented 6 years ago

it's great that this interests you. I will help any way I can (if i have time too )

Durman commented 6 years ago

Well, I have node that can show azimuth and altitude of the sun for current coordinates, date and time. It seems working.))

the sun 2018-01-29_11-38-33 2018-01-29_11-37-25

Durman commented 6 years ago

Moving of the sun during a year in my region. I think the node can become more interesting after appearing viewer node of lamp.

2018-01-29_15-24-13

enzyme69 commented 6 years ago

@Durman Is this awesome node available?

Durman commented 6 years ago

The node is not finished yet. I would not like to share while it is in bad condition. Also I noticed that Sverchok have not any nodes for working with time. I am thinking about adding time in/out and date in/out nodes.

Durman commented 6 years ago

Some examples with time nodes: I took 24 hours as 1.0. Thus it becomes possible to make all mathematical operation with the time as with simple number.

2018-01-30_11-43-22 2018-01-30_11-41-54 2018-01-30_12-49-20 2018-01-30_13-10-17

Durman commented 6 years ago

Output of date in node is integer number that show number of days between current date and initial date equal 1st year 1st month 1st day.

2018-01-31_13-57-35 2018-01-31_13-58-31

zeffii commented 6 years ago

i was parsing a csv lately and might want to add a node specially for datetime and time modules too.

import datetime

VC = []

for value in V1[0]:
    t = datetime.datetime.strptime(value, '%m/%d/%Y')
    m = t.toordinal() - 736600
    VC.append(m)

append(VC)
Durman commented 6 years ago

Something similar but I have done checking of input data for avoiding error of node. What is it 736600?

    for year,month,day in zip(*data):
        #Checking data
        def fit_data(data,min_d,max_d):
            if data < min_d:
                return min_d
            if data > max_d:
                return max_d
            else:
                return data

        year = fit_data(year,1,9999)
        month = fit_data(month,1,12)
        last_day_month = None
        if month in (1,3,5,7,8,10,12):
            last_day_month = 31
        elif month in (4,6,9,11):
            last_day_month = 30
        elif year % 4 == 0:
            last_day_month = 29
        else:
            last_day_month = 28
        day = fit_data(day,1,last_day_month)

        date = datetime.date(year,month,day)
        data_obj.append(date.toordinal())
zeffii commented 6 years ago

736600 was just a placeholder number, it marks the beginning of the data (ie the first entry), the result is a list of much smaller numbers that show the offset since the beginning.

Durman commented 6 years ago

I have six nodes now. Is it interesting to have something of this in master?

2018-02-02_08-20-33

enzyme69 commented 6 years ago

I am actually very okey with Script Node Lite :D Durman Folder.

zeffii commented 6 years ago

@Durman https://docs.python.org/3/library/calendar.html#calendar.monthrange

I think it can be written like this:


        import calendar
        ...
        ...
        year = fit_data(year,1,9999)
        month = fit_data(month,1,12)        
        wkday_first, last_day_month = calendar.monthrange(year, month)
nortikin commented 6 years ago

remindes me my script of dates https://github.com/nortikin/nikitron_tools/blob/master/%D0%B2%D1%8B%D0%BF%D0%B0%D0%B4%D0%B5%D0%BD%D0%B8%D0%B5%D0%B4%D0%BD%D0%B5%D0%B9.py

Durman commented 6 years ago

I have finished. Result is shared in first message.

nortikin commented 6 years ago

result is sun position? Or insolation at all?

Durman commented 6 years ago

I have spent most of my time creating sun position node. Also I created insolation calculation of course, it hadn't been difficult, I used almost only existing nodes. If it is interesting I can share with example of calculation.

nortikin commented 6 years ago

ok, please. if it is property send email

Durman commented 6 years ago

There is nothing tricky in the calculation for who knows SV.)) I will put here file tomorrow from my job.

nortikin commented 6 years ago

Main trouble is vectorizing. We need vectorized suncalc.

nortikin commented 6 years ago

there is task i solving now with conflict finding concept. In Revit you can see wall-celling intersection with engineering. So i do it revit_intersection

nortikin commented 6 years ago

revit_intersection1 теперь надо векторизировать, чтобы каждый объект прокручивался.

nortikin commented 6 years ago

И Задача ещё импортировать IFC формат

Durman commented 6 years ago

If there are questions I will answer.) К-16_2018_02_07_04_15.gz 2018-02-07_08-14-43

nortikin commented 6 years ago

not sure we do same way. now have same work on my job. maybe will snl on my own

nortikin commented 6 years ago

there is addon https://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/3D_interaction/Sun_Position that we can use for sun position indeed

nortikin commented 6 years ago

writing my new node for this stuff. it will do same as raycast mk2 object but with sun calculations hesitate to use hours or % in output

nortikin commented 6 years ago

my node shows hours of insolation and vertex color the initial object insolation1 insolation2

nortikin commented 6 years ago

the last thing to do - latitude and aptitude automatic estimation of sun directions It will calc for date from date time text node. So you will have three input nodes, one indices viewer and latitude and aptitude inputs

Durman commented 6 years ago

Your representation of insolation is very visual.)