Skip to content

Commit 91d26ff

Browse files
authored
Merge pull request #39 from NRCan/dev
new interface and tools for missing DRF entries rename sel to itemcode add cat lookup label table
2 parents 429c5a2 + 1a7bd61 commit 91d26ff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2358
-817
lines changed

.readthedocs.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: "2"
33
build:
44
os: "ubuntu-22.04"
55
tools:
6-
python: "3.10"
6+
python: "3.12"
77

88
python:
99
install:

CONTRIBUTING.md

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,33 @@
11
# CanCurve development
2+
guidelines/instructions for contributing to the CanCurve project.
3+
4+
For contributing to the documentation, see `./docs/contributing.MD`
25

36
## Installation
4-
Typically, development should employ a virtual environment with pyqgis bindings.
5-
We usually develop to target the most recent QGIS LTR.
6-
Some additional packages used for testing and deployment are specified in `./requirements.txt`
7+
Typically, development should employ a virtual environment with pyqgis bindings.
8+
To build this requires:
9+
- 1) pyqgis bindings (see `./readme.md` for target version)
10+
- 2) Some additional packages used for testing and deployment are specified in `./requirements.txt`
11+
- 3) a `./definitions.py` file is needed for some of the testing data (see below for template)
712

813
### PYTHONPATH
914
only the source directory should be included (`./CanCurve` not `./CanCurve/cancurve`)
1015

16+
17+
### definitions.py
18+
19+
```python
20+
#machine specific external filepaths
21+
#See Shared Drive/02_proj/2403_CanCurve/10_IO to download
22+
#https://drive.google.com/drive/folders/1Z0d40SdXU0bcI0l7CLO2aT6gYGhSu3cQ?usp=drive_link
23+
24+
#directory where test data is stored
25+
test_data_dir = r's:\02_proj\2403_CanCurve\10_IO\test_data'
26+
27+
#directory with DDFP data from David (for comparison)
28+
ddfp_data_dir = r's:\02_proj\2403_CanCurve\10_IO\DDF_data'
29+
```
30+
1131
## Tests
1232
pytests are in `./tests`
1333

README.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,19 @@ CanCurve is an open source tool for developing flood depth-damage (stage-damage)
1010

1111

1212
## Updates
13-
- 2024-12-04: update survey link [v1.0.3](https://github.com/NRCan/CanCurve/releases/tag/v1.0.3)
14-
- 2024-11-27: UI and documentation improvements.
15-
- 2024-10-31: add sphinx documentation. improve treatment of units. update to QGIS 3.34.12 [v1.0.0](https://github.com/NRCan/CanCurve/releases/tag/v1.0.0)
16-
- 2024-08-22: priority A and B fixes [v0.1.0](https://github.com/NRCan/CanCurve/releases/tag/v0.1.0)
17-
- 2024-05-09: small fixes and updates based on initial comments
18-
- 2024-05-01: initial working release (un tested) [v0.0.1](https://github.com/NRCan/CanCurve/releases/tag/v0.0.1)
13+
- [v1.1.0](https://github.com/NRCan/CanCurve/releases/tag/v1.1.0) post-release improvements
14+
- new interface and tools for missing DRF entries
15+
- rename sel to itemcode add cat lookup label table
16+
- [v1.0.3](https://github.com/NRCan/CanCurve/releases/tag/v1.0.3) pre-release
17+
1918

2019

2120
## Documentation
2221
Project documentation is [here](https://cancurve.readthedocs.io/en/latest/)
2322

2423

2524
## Installing for the first time
26-
- Install [QGIS 3.34.12](https://download.qgis.org/downloads/) (with Qt 5.15.13)
25+
- Install [QGIS 3.34.14](https://download.qgis.org/downloads/) (with Qt 5.15.13)
2726
- download the `cancurve.zip` file from the [latest release](https://github.com/NRCan/CanCurve/releases) to your local machine
2827
- in QGIS, `Manage and Install Plugins...` > `Install from ZIP` > select the downloaded file
2928
- we recommended to also install the **First Aid** plugin for more detailed error messages

cancurve/__init__.py

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#===============================================================================
22
# plugin metadata
33
#===============================================================================
4-
__version__='1.0.3'
4+
__version__='1.1.0'
55

66
#===============================================================================
77
# plugin entry point
@@ -25,13 +25,28 @@ def classFactory(iface): # pylint: disable=invalid-name
2525

2626
import importlib, warnings
2727

28+
from packaging import version
29+
2830
def check_package(package_name):
2931
spec = importlib.util.find_spec(package_name)
3032
if spec is not None:
31-
print(f'module {package_name} is installed')
33+
#print(f'module {package_name} is installed')
34+
pass
3235
else:
3336
warnings.warn(f'module \'{package_name}\' not installed')
3437

3538

3639
check_package('openpyxl')
3740

41+
42+
try:
43+
import pandas as pd
44+
except ImportError:
45+
warnings.warn("pandas is not installed!")
46+
else:
47+
required_version = "2.0.0"
48+
current_version = pd.__version__
49+
# Skeptically assert that the current pandas version meets the minimum requirement.
50+
assert version.parse(current_version) >= version.parse(required_version), (
51+
f"pandas version {current_version} is below the required {required_version}"
52+
)

cancurve/bldgs/assertions.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ def assert_ci_df(df, msg=''):
4545
raise TypeError("Input must be a Pandas DataFrame")
4646

4747
# Check index
48-
if not set(df.index.names).difference(['cat', 'sel']) == set():
49-
raise KeyError("Incorrect index names in DataFrame")
48+
if not set(df.index.names).difference(['category', 'component']) == set():
49+
raise KeyError(f"Incorrect index names in DataFrame\n {df.index.names}")
5050

5151
# Check data types
5252
for coln, dstr in df.dtypes.items():
@@ -149,12 +149,12 @@ def assert_drf_df(df):
149149
raise TypeError("Input must be a Pandas DataFrame")
150150

151151
# Check index
152-
if not set(df.index.names).difference(['cat', 'sel', 'bldg_layout']) == set():
152+
if not set(df.index.names).difference(['category', 'component', 'bldg_layout']) == set():
153153
raise KeyError("Incorrect index names in DataFrame")
154154

155155
# Check the columns all conform to float depths
156-
if not 'float' in df.columns.dtype.name:
157-
raise TypeError(f'DRF column headers expected as dtype float. instead got \'{df.columns.dtype.name}\'')
156+
# if not 'float' in df.columns.dtype.name:
157+
# raise TypeError(f'DRF column headers expected as dtype float. instead got \'{df.columns.dtype.name}\'')
158158

159159
# Check data types (more accurate)
160160

cancurve/bldgs/bldg_meta_rqmts.csv

+34-34
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
varName_core,varName_ui,varName_canflood,type,required_core,required_canflood,default_canflood,widgetName,case1,case2,case3,case4_R2,case5_crawl,01,case1_ci_header_case
2-
,,tag,str,FALSE,TRUE,?,,test_case1,test_case2,heather_0509,R_2-L-BD-CU_ABCA,R_1-L-C-ST_ABCA,tutorial_01,test_case1
3-
,currency,impact_units,str,FALSE,TRUE,$CAD,currency_ComboBox,,,,,,,
4-
,costBasis,impact_var,str,FALSE,FALSE,damage,costBasis_ComboBox,,,Depreciated Costs,,,,
5-
expo_units,expoUnits,exposure_units,str,FALSE,FALSE,meters,basementHeightUnits_label,meters,meters,meters,feet,meters,meters,meters
6-
,,exposure_var,str,FALSE,FALSE,flood depth above floor,,,,,,,,
7-
,,scale_var,str,FALSE,FALSE,building footprint,,,,,,,,
8-
bldg_layout,buildingLayout,,str,TRUE,FALSE,,buildingLayout_ComboBox,default,default,default,default,,default,default
9-
basement_height,basementHeight,,float,FALSE,FALSE,,basementHeight_DoubleSpinBox,1.8,2.1,0,10,0,1.8,1.8
10-
,sizeOrAreaValue,,float,FALSE,FALSE,,sizeOrAreaValue_DoubleSpinBox,232.1,232.2,344,139,232,232.1,232.1
11-
,sizeOrAreaUnits,scale_units,str,FALSE,FALSE,m2,sizeOrAreaUnits_ComboBox,m2,m2,m2,m2,m2,m2,m2
12-
scale_value_m2,,,float,TRUE,FALSE,,,232.1,232.2,344,139,232,232.1,232.1
13-
,,exposure,str,FALSE,TRUE,impact,,,,,,,,
14-
,occupancyClassification,,str,FALSE,FALSE,,occupancyClassification_ComboBox,,,Commercial,Residential,Residential,,
15-
,subClassification,,str,FALSE,FALSE,,subClassification_ComboBox,,,Construction,Single Family,,,
16-
,storys,,str,FALSE,FALSE,,storys_ComboBox,,,1,2,1,,
17-
,BedroomCount,,int,FALSE,FALSE,,BedroomCount_QSpinBox,,,0,7,,,
18-
,BathroomCount,,float,FALSE,FALSE,,BathroomCount_DoubleSpinBox,,,1,4,,,
19-
,heatingType,,str,FALSE,FALSE,,heatingType_ComboBox,,,Forced Air - Gas,Forced Air - Unknown,,,
20-
,coolingType,,str,FALSE,FALSE,,coolingType_ComboBox,,,Central air,Central air,,,
21-
,garageType,,str,FALSE,FALSE,,garageType_ComboBox,,,None,None,,,
22-
,garageSize,,str,FALSE,FALSE,,garageSize_ComboBox,,,,,,,
23-
,foundationType,,str,FALSE,FALSE,,foundationType_ComboBox,,,Other,Basement,Crawlspace,,
24-
,qualityOfBuildingMaterials,,str,FALSE,FALSE,,qualityOfBuildingMaterials_ComboBox,,,Average,Custom,Average,,
25-
,taxesIncluded,,str,FALSE,FALSE,,taxesIncluded_ComboBox,,,,,,,
26-
,priceListSource,,str,FALSE,FALSE,,priceListSource_LineEdit,,,Xactimate,,,,
27-
,country,,str,FALSE,FALSE,Canada,country_ComboBox,,,Canada,Canada,Canada,,
28-
,provinceTerritory,,str,FALSE,FALSE,,provinceTerritory_ComboBox,,,ON,AB,AB,,
29-
,pricingDate,,str,FALSE,FALSE,,,,,,,,,
30-
,basementFinish,,float,FALSE,FALSE,,basementFinish_DoubleSpinBox,,,100,100,,,
31-
,createdBy,,str,FALSE,FALSE,,createdBy_LineEdit,Arcadis,Arcadis,hmcgrath,Arcadis,Arcadis,Arcadis,Arcadis
32-
,locationCityTownRegion,,str,FALSE,FALSE,,,,,,,,,
33-
,yearOfBuildingConstruction,,int,FALSE,FALSE,,yearOfBuildingConstruction_SpinBox,,,2500,2000,2000,,
34-
scale_factor,scaleFactor,,float,TRUE,FALSE,,scaleFactor_DoubleSpinBox,1.1,1,1,1,1,1.1,1.1
1+
varName_core,varName_ui,varName_canflood,type,required_core,required_canflood,default_canflood,widgetName,case1,case2,case3,case4_R2,case5_crawl,01,02,case1_ci_header_case
2+
,,tag,str,FALSE,TRUE,?,,test_case1,test_case2,heather_0509,R_2-L-BD-CU_ABCA,R_1-L-C-ST_ABCA,tutorial_01,tutorial_01,test_case1
3+
,currency,impact_units,str,FALSE,TRUE,$CAD,currency_ComboBox,,,,,,,,
4+
,costBasis,impact_var,str,FALSE,FALSE,damage,costBasis_ComboBox,,,Depreciated Costs,,,,,
5+
expo_units,expoUnits,exposure_units,str,FALSE,FALSE,meters,basementHeightUnits_label,meters,meters,meters,feet,meters,meters,meters,meters
6+
,,exposure_var,str,FALSE,FALSE,flood depth above floor,,,,,,,,,
7+
,,scale_var,str,FALSE,FALSE,building footprint,,,,,,,,,
8+
bldg_layout,buildingLayout,,str,TRUE,FALSE,,buildingLayout_ComboBox,default,default,default,default,,default,default,default
9+
basement_height,basementHeight,,float,FALSE,FALSE,,basementHeight_DoubleSpinBox,1.8,2.1,0,10,0,1.8,1.8,1.8
10+
,sizeOrAreaValue,,float,FALSE,FALSE,,sizeOrAreaValue_DoubleSpinBox,232.1,232.2,344,139,232,232.1,232.1,232.1
11+
,sizeOrAreaUnits,scale_units,str,FALSE,FALSE,m2,sizeOrAreaUnits_ComboBox,m2,m2,m2,m2,m2,m2,m2,m2
12+
scale_value_m2,,,float,TRUE,FALSE,,,232.1,232.2,344,139,232,232.1,232.1,232.1
13+
,,exposure,str,FALSE,TRUE,impact,,,,,,,,,
14+
,occupancyClassification,,str,FALSE,FALSE,,occupancyClassification_ComboBox,,,Commercial,Residential,Residential,,,
15+
,subClassification,,str,FALSE,FALSE,,subClassification_ComboBox,,,Construction,Single Family,,,,
16+
,storys,,str,FALSE,FALSE,,storys_ComboBox,,,1,2,1,,,
17+
,BedroomCount,,int,FALSE,FALSE,,BedroomCount_QSpinBox,,,0,7,,,,
18+
,BathroomCount,,float,FALSE,FALSE,,BathroomCount_DoubleSpinBox,,,1,4,,,,
19+
,heatingType,,str,FALSE,FALSE,,heatingType_ComboBox,,,Forced Air - Gas,Forced Air - Unknown,,,,
20+
,coolingType,,str,FALSE,FALSE,,coolingType_ComboBox,,,Central air,Central air,,,,
21+
,garageType,,str,FALSE,FALSE,,garageType_ComboBox,,,None,None,,,,
22+
,garageSize,,str,FALSE,FALSE,,garageSize_ComboBox,,,,,,,,
23+
,foundationType,,str,FALSE,FALSE,,foundationType_ComboBox,,,Other,Basement,Crawlspace,,,
24+
,qualityOfBuildingMaterials,,str,FALSE,FALSE,,qualityOfBuildingMaterials_ComboBox,,,Average,Custom,Average,,,
25+
,taxesIncluded,,str,FALSE,FALSE,,taxesIncluded_ComboBox,,,,,,,,
26+
,priceListSource,,str,FALSE,FALSE,,priceListSource_LineEdit,,,Xactimate,,,,,
27+
,country,,str,FALSE,FALSE,Canada,country_ComboBox,,,Canada,Canada,Canada,,,
28+
,provinceTerritory,,str,FALSE,FALSE,,provinceTerritory_ComboBox,,,ON,AB,AB,,,
29+
,pricingDate,,str,FALSE,FALSE,,,,,,,,,,
30+
,basementFinish,,float,FALSE,FALSE,,basementFinish_DoubleSpinBox,,,100,100,,,,
31+
,createdBy,,str,FALSE,FALSE,,createdBy_LineEdit,Arcadis,Arcadis,hmcgrath,Arcadis,Arcadis,Arcadis,Arcadis,Arcadis
32+
,locationCityTownRegion,,str,FALSE,FALSE,,,,,,,,,,
33+
,yearOfBuildingConstruction,,int,FALSE,FALSE,,yearOfBuildingConstruction_SpinBox,,,2500,2000,2000,,,
34+
scale_factor,scaleFactor,,float,TRUE,FALSE,,scaleFactor_DoubleSpinBox,1.1,1,1,1,1,1.1,1.1,1.1

0 commit comments

Comments
 (0)