Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Acoustics module update #14

Merged
merged 38 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
4cabf5b
updated km to km2 in acoustics tab
tnelson-integral Aug 19, 2024
37d450c
Csv header refinement (#40)
tnelson-integral Aug 22, 2024
e2e4c92
Power module bugfix (#36)
tnelson-integral Aug 22, 2024
80d0914
Merge pull request #10 from sandialabs/main
tnelson-integral Aug 28, 2024
d07f4b1
git ignore update
tnelson-integral Aug 28, 2024
9cf2e1d
Merge remote-tracking branch 'origin/main' into acoustics_module_update
tnelson-integral Aug 28, 2024
02a5668
Add Testing Workflow (#37)
ssolson Aug 28, 2024
82d6042
Merge branch 'sandialabs:main' into main
tnelson-integral Aug 28, 2024
b763840
Merge remote-tracking branch 'origin/main' into acoustics_module_update
tnelson-integral Aug 28, 2024
f02d0e3
Black formatting (#43)
ssolson Aug 29, 2024
2dd59c3
Linting (#44)
ssolson Sep 3, 2024
6ca286b
Lint: Shear Stress & Power Modules (#45)
ssolson Sep 3, 2024
b25f928
create package with python script
tnelson-integral Sep 3, 2024
871305a
fixed typo
tnelson-integral Sep 3, 2024
5502cf4
fixed typo
tnelson-integral Sep 3, 2024
b833f1f
Lint: Stressor Utils Module (#46)
ssolson Sep 4, 2024
0c547a2
formatting fix
tnelson-integral Sep 4, 2024
6f0382c
bug fix
tnelson-integral Sep 4, 2024
c8204da
removed out of water weights
tnelson-integral Sep 4, 2024
42046a2
collapsed layers in qgis
tnelson-integral Sep 4, 2024
5ac2eb1
updated path
tnelson-integral Sep 4, 2024
2503138
fixed baseline error when not present
tnelson-integral Sep 4, 2024
51100b8
update icon location for missing toolbar icon
tnelson-integral Sep 4, 2024
25ef408
reversed order of layers in qgis
tnelson-integral Sep 4, 2024
80e0ac9
updated plugin
tnelson-integral Sep 4, 2024
eb80e59
Merge pull request #13 from sandialabs/main
tnelson-integral Sep 4, 2024
bab0c73
Lint: Stress Receptor Calc (#47)
ssolson Sep 5, 2024
8134509
Type hints (#48)
ssolson Sep 5, 2024
6f301a5
Merge branch 'main' into acoustics_module_update
tnelson-integral Sep 5, 2024
a4c46cb
Merge branch 'sandialabs:main' into main
tnelson-integral Sep 5, 2024
95a0c79
Merge branch 'main' into acoustics_module_update
tnelson-integral Sep 5, 2024
574d0e2
black formatting
tnelson-integral Sep 5, 2024
2807a44
formatting
tnelson-integral Sep 5, 2024
70d747c
formatting
tnelson-integral Sep 5, 2024
54d164e
updated parcousti preprocessing example
tnelson-integral Sep 5, 2024
b6318e4
formatting
tnelson-integral Sep 5, 2024
9f52ae3
update path
tnelson-integral Sep 5, 2024
2780bc1
added nc files
tnelson-integral Sep 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Black Code Formatter

on: [push, pull_request]

jobs:
black:
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.12"

- name: Install Black
run: |
python -m pip install --upgrade pip
pip install black

- name: Check Black Formatting
run: black --check .
72 changes: 72 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Pylint

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
linting:
runs-on: ubuntu-latest
services:
docker:
image: qgis/qgis:latest
options: --user root
ports:
- 99:99

steps:
- name: Checkout qgis-plugin
uses: actions/checkout@v4

- name: Run QGIS Docker container
run: |
docker run -d --name qgis-testing-environment \
-v ${GITHUB_WORKSPACE}:/tests_directory \
-e DISPLAY=:99 qgis/qgis:latest tail -f /dev/null

- name: Wait for Docker to be ready
run: |
until docker exec qgis-testing-environment sh -c "ls /"; do sleep 1; done

- name: Install plugin manually via Copy
run: |
docker exec qgis-testing-environment sh -c '
PLUGIN_SRC_PATH=/tests_directory/seat
PLUGIN_DEST_DIR=/usr/share/qgis/python/plugins/seat
mkdir -p $PLUGIN_DEST_DIR
cp -r $PLUGIN_SRC_PATH/* $PLUGIN_DEST_DIR/
'

- name: Install Dependencies
run: |
docker exec qgis-testing-environment sh -c "apt-get update && apt-get install -y python3-pandas python3-netcdf4"

- name: Create a Virtual Environment with system site packages
run: |
docker exec qgis-testing-environment sh -c "/usr/bin/python3.12 -m venv --system-site-packages /tests_directory/venv"

- name: Add Plugin to PYTHONPATH in Virtual Environment
run: |
docker exec qgis-testing-environment sh -c "echo '/usr/share/qgis/python/plugins' > /tests_directory/venv/lib/python3.12/site-packages/seat.pth"

- name: Install Pylint in Virtual Environment
run: |
docker exec qgis-testing-environment sh -c "/tests_directory/venv/bin/pip install pylint"

- name: Run Pylint
run: |
docker exec qgis-testing-environment sh -c "/tests_directory/venv/bin/pylint /tests_directory/seat/modules/velocity_module.py"
docker exec qgis-testing-environment sh -c "/tests_directory/venv/bin/pylint /tests_directory/seat/modules/shear_stress_module.py"
docker exec qgis-testing-environment sh -c "/tests_directory/venv/bin/pylint /tests_directory/seat/modules/power_module.py"
docker exec qgis-testing-environment sh -c "/tests_directory/venv/bin/pylint /tests_directory/seat/modules/stressor_utils.py"
docker exec qgis-testing-environment sh -c "/tests_directory/venv/bin/pylint /tests_directory/seat/stressor_receptor_calc.py"

- name: Clean up Docker container
if: always()
run: |
docker stop qgis-testing-environment
docker rm qgis-testing-environment
57 changes: 57 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: QGIS Plugin CI

on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
test-seat-package:
runs-on: ubuntu-latest
services:
docker:
image: qgis/qgis:latest
options: --user root
ports:
- 99:99

steps:
- name: Checkout qgis-plugin
uses: actions/checkout@v4

- name: Run QGIS Docker container
run: |
docker run -d --name qgis-testing-environment \
-v ${GITHUB_WORKSPACE}:/tests_directory \
-e DISPLAY=:99 qgis/qgis:latest tail -f /dev/null

- name: Wait for Docker to be ready
run: |
until docker exec qgis-testing-environment sh -c "ls /"; do sleep 1; done

- name: Install plugin manually via Copy
run: |
docker exec qgis-testing-environment sh -c '
PLUGIN_SRC_PATH=/tests_directory/seat
PLUGIN_DEST_DIR=/usr/share/qgis/python/plugins/seat
mkdir -p $PLUGIN_DEST_DIR
cp -r $PLUGIN_SRC_PATH/* $PLUGIN_DEST_DIR/
'

- name: Install Dependencies
run: |
docker exec qgis-testing-environment sh -c "python3 /tests_directory/tests/install_dependencies.py"
docker exec qgis-testing-environment sh -c "apt-get update && apt-get install -y python3-pandas python3-netcdf4 python3-pytest"

- name: Run Pytest
run: |
docker exec qgis-testing-environment pytest /tests_directory/tests

- name: Clean up Docker container
if: always()
run: |
docker stop qgis-testing-environment
docker rm qgis-testing-environment
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*cache*
*env*
*test_*
tester.ipynb

# Sphinx documentation html
docs/_build/*
23 changes: 23 additions & 0 deletions create_zip.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@echo off

set TIMESLOT=%date%
echo [%TIMESLOT%] START ...................... create_zip

echo [%TIMESLOT%] COPY ....................... .\seat -> .\seat_qgis_plugin
xcopy ".\seat" ".\seat_qgis_plugin" /E /I

set RELEASE=%TIMESLOT%
echo [%TIMESLOT%] ZIP ........................ %cd%\seat_qgis_plugin_%RELEASE%.zip

:: Requires PowerShell for zip functionality
powershell.exe -Command "Compress-Archive -Path '.\seat_qgis_plugin\*' -DestinationPath '.\seat_qgis_plugin_%RELEASE%.zip'"

echo [%TIMESLOT%] RM ......................... .\seat_qgis_plugin
if exist ".\seat_qgis_plugin" (
rmdir /s /q ".\seat_qgis_plugin"
) else (
echo Directory not found: .\seat_qgis_plugin
)

set ENDTIME=%YEAR%_%MONTH%_%DAY%.%HOUR%_%MIN%
echo [%TIMESLOT%] END ........................ create_release
48 changes: 48 additions & 0 deletions create_zip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import shutil
import os
from datetime import datetime


def copy_directory(src, dest, exclude_dirs):
exclude_dirs = [os.path.join(src, ex) for ex in exclude_dirs]

for root, dirs, files in os.walk(src):
# Construct the destination path
dest_path = root.replace(src, dest, 1)

# Skip excluded directories
dirs[:] = [d for d in dirs if os.path.join(root, d) not in exclude_dirs]

# Create the destination directory if it doesn't exist
if not os.path.exists(dest_path):
os.makedirs(dest_path)

# Copy files
for file in files:
src_file = os.path.join(root, file)
dest_file = os.path.join(dest_path, file)
shutil.copy2(src_file, dest_file)


exclude_dirs = [r".git", r".github", r".vscode", r"__pycache__"]

directory_path = os.path.join(os.getcwd(), r"seat")

if os.path.exists(directory_path):
package_path = os.path.join(directory_path, r"seat_qgis_plugin", r"seat")
print(r"Creating Package")

if os.path.exists(os.path.dirname(package_path)):
shutil.rmtree(os.path.dirname(package_path))

copy_directory(directory_path, package_path, exclude_dirs)

current_date = datetime.now().strftime("%Y%m%d")
output_filename = f"seat_qgis_plugin_{current_date}"

# Create a zip archive of the directory
shutil.make_archive(output_filename, "zip", os.path.dirname(package_path))
print(f"Zip archive {output_filename} created successfully")
shutil.rmtree(os.path.dirname(package_path))
else:
print("Directory ./seat not found. Validate current directory")
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sphinx_rtd_theme
sphinx_rtd_dark_mode
sphinx_copybutton
sphinx_autodoc_typehints
sphinx_autodoc_typehints
24 changes: 12 additions & 12 deletions docs/src/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

# -- Project information -----------------------------------------------------

project = 'SEAT'
copyright = '2023 Sandia National Laboratories'
author = 'Tim Nelson, Caleb Grant, Eben Pendleton, Sterling Olson'
project = "SEAT"
copyright = "2023 Sandia National Laboratories"
author = "Tim Nelson, Caleb Grant, Eben Pendleton, Sterling Olson"

# The full version, including alpha/beta/rc tags
release = '[1.0.0-beta1]'
release = "[1.0.0-beta1]"


# -- General configuration ---------------------------------------------------
Expand All @@ -33,13 +33,13 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.napoleon',
'sphinx.ext.intersphinx',
'sphinx_autodoc_typehints',
'sphinx_rtd_theme',
'sphinx_rtd_dark_mode',
'sphinx_copybutton',
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
"sphinx.ext.intersphinx",
"sphinx_autodoc_typehints",
"sphinx_rtd_theme",
"sphinx_rtd_dark_mode",
"sphinx_copybutton",
]

# Add any paths that contain templates here, relative to this directory.
Expand All @@ -48,7 +48,7 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]


# Napoleon settings
Expand Down
26 changes: 13 additions & 13 deletions docs/src/media/compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,37 @@ def compress_image(image_path, output_path, quality=100):
The quality parameter controls the quality of the compression.
Lowering the quality value will decrease the file size.
"""
image = Image.open(image_path).convert(
'RGB') # Ensure the image is in RGB mode
image = Image.open(image_path).convert("RGB") # Ensure the image is in RGB mode
max_width = 1000
width_percent = (max_width / float(image.size[0]))
width_percent = max_width / float(image.size[0])
height_size = int((float(image.size[1]) * float(width_percent)))
resized_img = image.resize((max_width, height_size), Image.ANTIALIAS)

resized_img.save(output_path, 'WEBP', quality=quality)
resized_img.save(output_path, "WEBP", quality=quality)


def process_single_png(filename):
if not filename.endswith('.png'):
if not filename.endswith(".png"):
print(f"{filename} is not a .png file.")
return

print(f"Processing {filename}...")
file_path = filename
output_path = os.path.splitext(file_path)[0] + '.webp'
output_path = os.path.splitext(file_path)[0] + ".webp"

# Convert PNG to WEBP without compressing, just for the format change
image = Image.open(file_path).convert('RGB')
image.save(output_path, 'WEBP')
image = Image.open(file_path).convert("RGB")
image.save(output_path, "WEBP")

print(f"{filename} converted to {os.path.basename(output_path)}\n")


def process_webp_files():
for filename in os.listdir('.'):
if filename.endswith('.webp'):
for filename in os.listdir("."):
if filename.endswith(".webp"):
print(f"Processing {filename}...")
file_path = os.path.join('.', filename)
output_path = os.path.splitext(file_path)[0] + '.webp'
file_path = os.path.join(".", filename)
output_path = os.path.splitext(file_path)[0] + ".webp"

# Get initial file size in kB
initial_file_size_kb = os.path.getsize(file_path) / 1024
Expand All @@ -55,7 +54,8 @@ def process_webp_files():
# Get final file size in kB
final_file_size_kb = os.path.getsize(output_path) / 1024
print(
f"{os.path.basename(output_path)}: Final Size: {final_file_size_kb:.2f} kB\n")
f"{os.path.basename(output_path)}: Final Size: {final_file_size_kb:.2f} kB\n"
)


def main():
Expand Down
18 changes: 6 additions & 12 deletions seat/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
# -*- coding: utf-8 -*-
"""
/***************************************************************************.

StressorReceptorCalc
A QGIS plugin
This calculates a response layer from stressor and receptor layers
Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/
-------------------
begin : 2021-04-19
copyright : (C) 2021 by Integral Consultsing
email : [email protected]
git sha : $Format:%H$
Name : seat
Date : 2021-04-19
Contact : https://github.com/sandialabs/seat-qgis-plugin
***************************************************************************/

/***************************************************************************
Expand All @@ -25,9 +18,10 @@
"""


# noinspection PyPep8Naming
def classFactory(iface): # pylint: disable=invalid-name
"""Load StressorReceptorCalc class from file StressorReceptorCalc.
"""
Load StressorReceptorCalc class from file StressorReceptorCalc.
A QGIS plugin calculates a response layer from stressor and receptor layers

:param iface: A QGIS interface instance.
:type iface: QgsInterface
Expand Down
Loading
Loading