Skip to content

Commit 4d01c26

Browse files
committed
update doc
1 parent ca524a7 commit 4d01c26

File tree

8 files changed

+132
-14
lines changed

8 files changed

+132
-14
lines changed

docs/source/analysis.rst

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
.. _analysis:
2+
3+
4+
*****************************
5+
Shadow coverage analysis
6+
*****************************
7+
8+
9+
Shadow coverage analysis
10+
--------------------------------------
11+
12+
.. function:: pybdshadow.cal_sunshadows(buildings, cityname='somecity', dates=['2022-01-01'], gap=3600,roof=True, include_building=True,save_shadows=False,printlog=False)
13+
14+
Calculate the sunlight shadow in different date with given time gap.
15+
16+
**Parameters**
17+
18+
buildings : GeoDataFrame
19+
Buildings. coordinate system should be WGS84
20+
cityname : string
21+
Cityname. If save_shadows, this function will create `result/cityname` folder to save the shadows
22+
dates : list
23+
list of dates
24+
gap : number
25+
time gap(s)
26+
roof : bool
27+
whether to calculate roof shadow.
28+
include_building : bool
29+
whether the shadow include building outline
30+
save_shadows : bool
31+
whether to save calculated shadows
32+
printlog : bool
33+
whether to print log
34+
35+
**Return**
36+
37+
allshadow : GeoDataFrame
38+
All building shadows calculated
39+
40+
41+
.. function:: pybdshadow.cal_shadowcoverage(shadows_input,buildings,roof=True,gap = 3600,accuracy=1)
42+
43+
Calculate the sunlight shadow coverage time for given area.
44+
45+
**Parameters**
46+
47+
shadows_input : GeoDataFrame
48+
All building shadows calculated
49+
buildings : GeoDataFrame
50+
Buildings. coordinate system should be WGS84
51+
roof : bool
52+
If true roof shadow, false then ground shadow
53+
gap : number
54+
time gap(s), which is for calculation of coverage time
55+
accuracy : number
56+
size of grids.
57+
58+
**Return**
59+
60+
bdgrids : GeoDataFrame
61+
grids generated by TransBigData in study area, each grids have a `time` column store the shadow coverage time
62+
63+
64+

docs/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
author = 'Qing Yu'
2323

2424
# The full version, including alpha/beta/rc tags
25-
release = '0.2.4'
26-
version = '0.2.4'
25+
release = '0.3.0'
26+
version = '0.3.0'
2727
html_logo = "_static/logo-wordmark-light.png"
2828
html_favicon = '_static/logo.ico'
2929
# -- General configuration ---------------------------------------------------

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,5 @@ Citation information can be found at https://github.com/ni1o1/pybdshadow/blob/ma
6262

6363
preprocess.rst
6464
bdshadow.rst
65+
analysis.rst
6566
Visualization.rst

example/example-analysis.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
],
153153
"source": [
154154
"#Grid analysis of shadow cover duration(roof).\n",
155-
"bdgrids = pybdshadow.cal_shadowduration(shadows,buildings,gap = 1800,accuracy=2)\n",
155+
"bdgrids = pybdshadow.cal_shadowcoverage(shadows,buildings,gap = 1800,accuracy=2)\n",
156156
"\n",
157157
"#Visualize buildings and shadows using matplotlib\n",
158158
"import matplotlib.pyplot as plt\n",
@@ -196,7 +196,7 @@
196196
],
197197
"source": [
198198
"#Grid analysis of shadow cover duration(ground).\n",
199-
"bdgrids = pybdshadow.cal_shadowduration(shadows,buildings,roof=False,gap = 900,accuracy=2)\n",
199+
"bdgrids = pybdshadow.cal_shadowcoverage(shadows,buildings,roof=False,gap = 900,accuracy=2)\n",
200200
"\n",
201201
"#Visualize buildings and shadows using matplotlib\n",
202202
"import matplotlib.pyplot as plt\n",

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="pybdshadow",
8-
version="0.2.4",
8+
version="0.3.0",
99
author="Qing Yu",
1010
author_email="qingyu0815@foxmail.com",
1111
description="Python package to generate building shadow geometry",

src/pybdshadow/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3333
"""
3434

35-
__version__ = '0.2.4'
35+
__version__ = '0.3.0'
3636
__author__ = 'Qing Yu <qingyu0815@foxmail.com>'
3737

3838
# module level doc-string
@@ -52,11 +52,13 @@
5252
)
5353
from .analysis import (
5454
cal_sunshadows,
55-
cal_shadowduration
55+
cal_shadowcoverage
5656
)
5757

5858
__all__ = ['bdshadow_sunlight',
5959
'bdshadow_pointlight',
6060
'bd_preprocess',
6161
'show_bdshadow',
62+
'cal_sunshadows',
63+
'cal_shadowcoverage',
6264
]

src/pybdshadow/analysis.py

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import pandas as pd
22
from suncalc import get_times
3+
from shapely.geometry import MultiPolygon
4+
import transbigdata as tbd
5+
import geopandas as gpd
36
from .pybdshadow import (
47
bdshadow_sunlight,
58
)
69
from .preprocess import bd_preprocess
7-
# 生成时间表
8-
def get_timetable(lon, lat, dates=['2022-01-01'], gap=3600, padding=1800):
910

11+
12+
def get_timetable(lon, lat, dates=['2022-01-01'], gap=3600, padding=1800):
13+
# generate timetable
1014
def get_timeSeries(day, lon, lat, gap=3600, padding=1800):
1115
date = pd.to_datetime(day+' 12:45:33.959797119')
1216
times = get_times(date, lon, lat)
@@ -27,6 +31,33 @@ def get_timeSeries(day, lon, lat, gap=3600, padding=1800):
2731

2832
def cal_sunshadows(buildings, cityname='somecity', dates=['2022-01-01'], gap=3600,
2933
roof=True, include_building=True,save_shadows=False,printlog=False):
34+
'''
35+
Calculate the sunlight shadow in different date with given time gap.
36+
37+
**Parameters**
38+
39+
buildings : GeoDataFrame
40+
Buildings. coordinate system should be WGS84
41+
cityname : string
42+
Cityname. If save_shadows, this function will create `result/cityname` folder to save the shadows
43+
dates : list
44+
list of dates
45+
gap : number
46+
time gap(s)
47+
roof : bool
48+
whether to calculate roof shadow.
49+
include_building : bool
50+
whether the shadow include building outline
51+
save_shadows : bool
52+
whether to save calculated shadows
53+
printlog : bool
54+
whether to print log
55+
56+
**Return**
57+
58+
allshadow : GeoDataFrame
59+
All building shadows calculated
60+
'''
3061
# 获取城市位置
3162
lon, lat = buildings['geometry'].iloc[0].bounds[:2]
3263
timetable = get_timetable(lon, lat, dates, gap)
@@ -61,10 +92,30 @@ def cal_sunshadows(buildings, cityname='somecity', dates=['2022-01-01'], gap=360
6192
allshadow = pd.concat(allshadow)
6293
return allshadow
6394

64-
from shapely.geometry import MultiPolygon
65-
import transbigdata as tbd
66-
import geopandas as gpd
67-
def cal_shadowduration(shadows_input,buildings,roof=True,gap = 3600,accuracy=1):
95+
96+
def cal_shadowcoverage(shadows_input,buildings,roof=True,gap = 3600,accuracy=1):
97+
'''
98+
Calculate the sunlight shadow coverage time for given area.
99+
100+
**Parameters**
101+
102+
shadows_input : GeoDataFrame
103+
All building shadows calculated
104+
buildings : GeoDataFrame
105+
Buildings. coordinate system should be WGS84
106+
roof : bool
107+
If true roof shadow, false then ground shadow
108+
gap : number
109+
time gap(s), which is for calculation of coverage time
110+
accuracy : number
111+
size of grids.
112+
113+
**Return**
114+
115+
bdgrids : GeoDataFrame
116+
grids generated by TransBigData in study area, each grids have a `time` column store the shadow coverage time
117+
118+
'''
68119
shadows = bd_preprocess(shadows_input)
69120
if roof:
70121
ground_shadows = shadows[shadows['type']=='roof'].groupby(['date'])['geometry'].apply(

src/pybdshadow/tests/test_analysis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ def test_analysis(self):
3030
#分析
3131
date = '2022-01-01'
3232
shadows = pybdshadow.cal_sunshadows(buildings,dates = [date],gap=3600)
33-
bdgrids = pybdshadow.cal_shadowduration(shadows,buildings,gap = 3600,accuracy=2)
33+
bdgrids = pybdshadow.cal_shadowcoverage(shadows,buildings,gap = 3600,accuracy=2)
3434
assert len(bdgrids)==1185

0 commit comments

Comments
 (0)