Skip to content

Commit

Permalink
fix(map): Add binary option to several functions (#65)
Browse files Browse the repository at this point in the history
* fix(map): Add binary option to several functions

* ci(ci): Update semantic release to avoid secondary rate limit

* docs(map): Describe main difference between plain text and binary

* refactor(map): Change input name from plain_text to output_format
  • Loading branch information
mikkelkp authored Jul 29, 2024
1 parent a483ab0 commit fd7806d
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 11 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
python-version: '3.10'
- name: install python dependencies
run: |
pip install -r dev-requirements.txt
Expand All @@ -37,9 +37,9 @@ jobs:
with:
python-version: 3.7
- name: set up node # we need node for for semantic release
uses: actions/setup-node@v2.1.2
uses: actions/setup-node@v4
with:
node-version: 14.2.0
node-version: 22.2.0
- name: install python dependencies
run: |
pip install -r dev-requirements.txt
Expand All @@ -50,8 +50,8 @@ jobs:
- name: run semantic release
id: new_release
run: |
nextRelease="`npx semantic-release@^17.0.0 --dryRun | grep -oP 'Published release \K.*? ' || true`"
npx semantic-release@^17.0.0
nextRelease="`npx semantic-release@^23.1.1 --dryRun | grep -oP 'Published release \K.*? ' || true`"
npx semantic-release@^23.1.1
echo "::set-output name=tag::$nextRelease"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pytest==6.2.3
pytest==6.2.5
twine==3.4.1
wheel==0.36.2
setuptools==56.0.0
49 changes: 45 additions & 4 deletions pollination/ladybug_comfort/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,24 @@ class UtciMap(Function):
'will be for the entire result_sql run period.', default=''
)

output_format = Inputs.str(
description='Flag to note whether the output should be formatted as a '
'plain text CSV or whether it should be formatted as a binary numpy '
'array. Using binary will decrease the file size, however, to read the '
'contents of the file you have to pass it through numpy, whereas the '
'plain text file can be opened in a text editor.',
default='plain-text',
spec={'type': 'string', 'enum': ['plain-text', 'binary']}
)

@command
def run_utci_map(self):
return 'ladybug-comfort map utci result.sql enclosure_info.json ' \
'weather.epw --total-irradiance total.ill --direct-irradiance direct.ill ' \
'--ref-irradiance ref.ill --sun-up-hours sun-up-hours.txt ' \
'--wind-speed "{{self.wind_speed}}" --solarcal-par ' \
'"{{self.solarcal_par}}" --comfort-par "{{self.comfort_par}}" ' \
'--run-period "{{self.run_period}}" --folder output'
'--run-period "{{self.run_period}}" --{{self.output_format}} --folder output'

result_folder = Outputs.folder(
description='Folder containing all of the output CSV files.', path='output'
Expand Down Expand Up @@ -464,14 +474,24 @@ class ShortwaveMrtMap(Function):
spec={'type': 'string', 'enum': ['is-indirect', 'indirect-is-total']}
)

output_format = Inputs.str(
description='Flag to note whether the output should be formatted as a '
'plain text CSV or whether it should be formatted as a binary numpy '
'array. Using binary will decrease the file size, however, to read the '
'contents of the file you have to pass it through numpy, whereas the '
'plain text file can be opened in a text editor.',
default='plain-text',
spec={'type': 'string', 'enum': ['plain-text', 'binary']}
)

@command
def run_shortwave_map(self):
return 'ladybug-comfort map shortwave-mrt weather.epw indirect.ill direct.ill ' \
'ref.ill sun-up-hours.txt --contributions dynamic ' \
'--transmittance-contribs dyn_shade --trans-schedule-json ' \
'trans_schedules.json --solarcal-par "{{self.solarcal_par}}" ' \
'--run-period "{{self.run_period}}" --{{self.indirect_is_total}} ' \
'--output-file shortwave.csv'
'--{{self.output_format}} --output-file shortwave.csv'

shortwave_mrt_map = Outputs.file(
description='CSV file containing a map of shortwave MRT deltas.',
Expand Down Expand Up @@ -516,11 +536,22 @@ class LongwaveMrtMap(Function):
'will be annual.', default=''
)

output_format = Inputs.str(
description='Flag to note whether the output should be formatted as a '
'plain text CSV or whether it should be formatted as a binary numpy '
'array. Using binary will decrease the file size, however, to read the '
'contents of the file you have to pass it through numpy, whereas the '
'plain text file can be opened in a text editor.',
default='plain-text',
spec={'type': 'string', 'enum': ['plain-text', 'binary']}
)

@command
def run_longwave_map(self):
return 'ladybug-comfort map longwave-mrt result.sql view_factors.csv ' \
'view_factors.mod enclosure_info.json weather.epw ' \
'--run-period "{{self.run_period}}" --output-file longwave.csv'
'--run-period "{{self.run_period}}" --{{self.output_format}} ' \
'--output-file longwave.csv'

longwave_mrt_map = Outputs.file(
description='CSV file containing a map of longwave MRT.',
Expand Down Expand Up @@ -563,11 +594,21 @@ class AirMap(Function):
spec={'type': 'string', 'enum': ['air-temperature', 'relative-humidity']}
)

output_format = Inputs.str(
description='Flag to note whether the output should be formatted as a '
'plain text CSV or whether it should be formatted as a binary numpy '
'array. Using binary will decrease the file size, however, to read the '
'contents of the file you have to pass it through numpy, whereas the '
'plain text file can be opened in a text editor.',
default='plain-text',
spec={'type': 'string', 'enum': ['plain-text', 'binary']}
)

@command
def run_air_map(self):
return 'ladybug-comfort map air result.sql enclosure_info.json weather.epw ' \
'--run-period "{{self.run_period}}" --{{self.metric}} ' \
'--output-file air.csv'
'--{{self.output_format}} --output-file air.csv'

air_map = Outputs.file(
description='CSV file containing a map of air temperatures or humidity.',
Expand Down
13 changes: 12 additions & 1 deletion pollination/ladybug_comfort/mtx.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,23 @@ class UtciMtx(Function):
'the UTCI comfort model.', default='--cold 9 --heat 26'
)

output_format = Inputs.str(
description='Flag to note whether the output should be formatted as a '
'plain text CSV or whether it should be formatted as a binary numpy '
'array. Using binary will decrease the file size, however, to read the '
'contents of the file you have to pass it through numpy, whereas the '
'plain text file can be opened in a text editor.',
default='plain-text',
spec={'type': 'string', 'enum': ['plain-text', 'binary']}
)

@command
def run_utci_mtx(self):
return 'ladybug-comfort mtx utci air_temperature.csv rel_humidity.csv ' \
'--rad-temperature-mtx rad_temperature.csv --rad-delta-mtx rad_delta.csv ' \
'--wind-speed-json wind_speed.json --air-speed-mtx air_speed.csv ' \
'--comfort-par "{{self.comfort_par}}" --folder output'
'--comfort-par "{{self.comfort_par}}" --{{self.output_format}} ' \
'--folder output'

result_folder = Outputs.folder(
description='Folder containing all of the output CSV files.', path='output'
Expand Down

0 comments on commit fd7806d

Please sign in to comment.