Skip to content

Commit

Permalink
feat(radolan loader): allow multiselect radolan files (version 1.8)
Browse files Browse the repository at this point in the history
  • Loading branch information
Weathermann committed Apr 21, 2024
1 parent a775436 commit 0b3c127
Show file tree
Hide file tree
Showing 11 changed files with 506 additions and 498 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ resources.py
zip_build/
# VS Code
.vscode
news.txt
21 changes: 7 additions & 14 deletions classes/ASCIIGridWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@
from pathlib import Path
import numpy as np

from NumpyRadolanReader import NumpyRadolanReader
from .NumpyRadolanReader import NumpyRadolanReader

default_nodata_value = -1.0


class ASCIIGridWriter:
"""
ASCIIGridWriter
"""ASCIIGridWriter
Creates a ESRI ASCII GRID (to convert this to GeoTIFF afterwards)
from original binary RADOLAN file
Created on 06.12.2020
@author: Weatherman
"""
@author: Weatherman"""


def __init__(self, np_2Ddata, precision, asc_filename_path, nodata_value=default_nodata_value):
"""
:param np_2Ddata:
Expand All @@ -41,8 +38,7 @@ def __init__(self, np_2Ddata, precision, asc_filename_path, nodata_value=default

if nodata_value != default_nodata_value:
self.out(f"nodata_value: {nodata_value}")



def __str__(self):
return self.__class__.__name__

Expand All @@ -51,7 +47,6 @@ def out(self, s, ok=True):
print(f"{self}: {s}")
else:
print(f"{self}: {s}", file=sys.stderr)


def write(self):
"""
Expand Down Expand Up @@ -85,17 +80,15 @@ def write(self):
l_gis_header_template.append(f"nodata_value {self._nodata_value}")

gis_header = "\n".join(l_gis_header_template)



# precision: 1.0, 0.1, 0.01
if self._prec == 0.1:
fmt = '%.1f'
elif self._prec == 0.01:
fmt = '%.2f'
else:
fmt = '%d' # as integer



np_data = np.copy(self._np_2Ddata) # otherwise values will be changed

#mask = np.isnan(np_data)
Expand All @@ -105,7 +98,7 @@ def write(self):

# np.flipud(): Flip array in the up/down direction.
np.savetxt(self._asc_filename_path, np.flipud(np_data), fmt=fmt,
delimiter=' ', newline='\n', header=gis_header, comments='') # footer=''
delimiter=' ', newline='\n', header=gis_header, comments='') # footer=''

self.out(f"write(): -> {self._asc_filename_path}")

Expand Down
19 changes: 4 additions & 15 deletions classes/ActionTabBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@


class ActionTabBase:
"""
ActionTabBase
""" ActionTabBase
Base class of all specialized tab classes
Expand All @@ -19,16 +18,14 @@ class ActionTabBase:
Created on 19.12.2020
@author: Weatherman
"""



def __init__(self, iface, model, dock):
print(self)

self._iface = iface
self._model = model
self.dock = dock


def __str__(self):
return self.__class__.__name__

Expand All @@ -37,18 +34,15 @@ def out(self, s, ok=True):
print(f"{self}: {s}")
else:
print(f"{self}: {s}", file=sys.stderr)


def _show_critical_message_box(self, msg, caption='Exception catched'):
self.out(msg, False)
QMessageBox.critical(self._iface.mainWindow(), caption, msg)


def _enable_and_show_statistics_tab(self):
def _enable_and_show_statistics_tab(self): # TODO 11.03.2024: replace with method in 'gui.py'?
self.dock.tabWidget.setTabEnabled(self.dock.TAB_STATISTICS, True)
self.dock.tabWidget.setCurrentIndex(self.dock.TAB_STATISTICS) # show statistics tab


def _check_create_project(self):
"""
If no project file not loaded when running plugin
Expand All @@ -72,12 +66,10 @@ def _check_create_project(self):
self.out(f"write: {new_file}")
project.write(str(new_file))


def _finish(self):
""" prints a unified message at end of operation """
self.out("*** Whole process finished! ***")



def _load_print_layout(self, layer_name, prod_id, dt=None):
window_title = "Print" # will be checked with a found composer title

Expand Down Expand Up @@ -241,7 +233,6 @@ def _load_print_layout(self, layer_name, prod_id, dt=None):
# Also note that active_composer.composerWindow() has a hide() and show()
#active_composer.composerWindow().hide() # works


def _create_qdocument_from_print_template_content(self):
print_template = self._model.default_print_template

Expand All @@ -261,5 +252,3 @@ def _create_qdocument_from_print_template_content(self):
q_xmldoc.setContent(print_template_content, False) # , bool namespaceProcessing

return q_xmldoc


Loading

0 comments on commit 0b3c127

Please sign in to comment.