koronascript 0.1__tar.gz → 0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,11 +27,11 @@ class KoronaModule():
27
27
  self._name = name
28
28
  self._config = {}
29
29
  # Add defaults
30
- for k,v in modules_spec[name].items():
30
+ for k, v in modules_spec[name].items():
31
31
  self._config[k] = v
32
32
 
33
33
  for k in parameters:
34
- if k != 'Active' and not k in modules_spec[name]:
34
+ if k != 'Active' and k not in modules_spec[name]:
35
35
  print(f'Parameter "{k}" not valid for Korona module "{name}" - aborting')
36
36
  exit(-1)
37
37
  self._config[k] = parameters[k]
@@ -45,18 +45,18 @@ class KoronaModule():
45
45
  for k in self._config:
46
46
  if self._config[k] is None:
47
47
  res += f' <parameter name="{k}"/>\n'
48
- elif isinstance(self._config[k],list):
48
+ elif isinstance(self._config[k], list):
49
49
  res += f' <parameter name="{k}">'
50
50
  for v in self._config[k]:
51
- res += str(v)+','
52
- res = res[:-1] # remove last comma
51
+ res += str(v) + ','
52
+ res = res[:-1] # remove last comma
53
53
  res += '</parameter>\n'
54
- elif isinstance(self._config[k],dict):
54
+ elif isinstance(self._config[k], dict):
55
55
  res += f' <parameter name="{k}">\n'
56
56
  # Should maybe call recursively? Can they be lists or dicts?
57
- for key,val in self._config[k].items():
57
+ for key, val in self._config[k].items():
58
58
  res += f' <parameter name="{key}">{val}</parameter>\n'
59
- res += ' </parameter>\n'
59
+ res += ' </parameter>\n'
60
60
  else:
61
61
  res += (f' <parameter name="{k}">{self._config[k]}</parameter>\n')
62
62
  res += (' </parameters>\n')
@@ -1,6 +1,6 @@
1
1
  # Auto-generated, do not edit directly
2
2
  # see genmodule.py
3
- from .Configuration import modules_spec
3
+
4
4
  from .KoronaModule import KoronaModule
5
5
 
6
6
  class AngleDeletion(KoronaModule):
@@ -292,4 +292,3 @@ class NetcdfWriter(KoronaModule):
292
292
  """Writes to a .nc file"""
293
293
  def __init__(self, **parameters):
294
294
  super().__init__('NetcdfWriter', **parameters)
295
-
@@ -10,14 +10,17 @@ import subprocess
10
10
  import tempfile
11
11
  import os
12
12
  import sys
13
- import json
14
13
 
15
- from .KoronaModule import KoronaModule, global_spec
14
+ from .KoronaModule import global_spec
15
+
16
+ lsss = os.getenv('LSSS')
17
+ if lsss is None:
18
+ print('KoronaScript: Warning: $LSSS is not set.')
16
19
 
17
20
  class KoronaScript():
18
21
  '''Construct, store, and run a set of Korona modules'''
19
22
 
20
- def __init__(self, **parameters): # global parameters
23
+ def __init__(self, **parameters): # global parameters
21
24
  self._module_list = []
22
25
  self._config = global_spec
23
26
  for k in parameters:
@@ -36,7 +39,7 @@ class KoronaScript():
36
39
  cfs.write('<?xml version="1.0" encoding="UTF-8"?>\n\n')
37
40
  cfs.write('<ConfigFiles context="Korona">\n')
38
41
  cfs.write(f' <parameter name="ModuleConfiguration" ref="CfsDirectory">{cdsname}</parameter>\n')
39
- for k,v in self._config.items():
42
+ for k, v in self._config.items():
40
43
  if v is None:
41
44
  cfs.write(f' <parameter name="{k}"/>\n')
42
45
  else:
@@ -60,17 +63,21 @@ class KoronaScript():
60
63
  self.write(cfs=cfsfd, cds=cdsfd, cdsname=cdsname)
61
64
 
62
65
  # if os.getenv('JAVA_HOME'): (...)
63
- lsss = os.getenv('LSSS')
64
66
  if lsss is None:
65
- print('LSSS environment variable not specified')
67
+ print('KoronaScript: Error: LSSS environment variable not specified')
66
68
  exit(-1)
67
69
  os.environ['TOP_INSTALLATION_DIR'] = lsss
68
70
 
69
- java = lsss+'/jre/bin/java'
71
+ java = os.path.join(*[lsss, 'jre', 'bin', 'java'])
72
+
73
+ # "-Xmx${MAX_MEMORY_MB}m" -classpath "t$TOP_INSTALLATION_DIR/lib/jar/*" "-Djava.library.path=$JAVA_LIBRARY_PATH" "-Djna.library.path=$JAVA_LIBRARY_PATH" -XX:-UseGCOverheadLimit -XX:-OmitStackTraceInFastThrow -Dno.marec.incubator=true no.imr.korona.main.KoronaCliMain "$@"
74
+ javaopts = ['-classpath', os.path.join(*[lsss, "lib", "jar", "*"]), '-Dno.marec.incubator=true']
75
+ libpath = os.path.join(*[lsss, 'lib', 'native', 'win64'])
76
+ if os.path.exists(libpath):
77
+ for v in ['java.library.path', 'jna.library.path']:
78
+ javaopts.append(f'-D{v}={libpath}')
70
79
 
71
- # "-Xmx${MAX_MEMORY_MB}m" -classpath "$TOP_INSTALLATION_DIR/lib/jar/*" "-Djava.library.path=$JAVA_LIBRARY_PATH" "-Djna.library.path=$JAVA_LIBRARY_PATH" -XX:-UseGCOverheadLimit -XX:-OmitStackTraceInFastThrow -Dno.marec.incubator=true no.imr.korona.main.KoronaCliMain "$@"
72
- javaopts = ['-classpath', f'{lsss}/lib/jar/*', '-Dno.marec.incubator=true', 'no.imr.korona.main.KoronaCliMain']
73
- res = subprocess.run([java] + javaopts + ['batch', '--cfs', cfsname, '--source', src, '--destination', dst])
80
+ res = subprocess.run([java] + javaopts + ['no.imr.korona.main.KoronaCliMain', 'batch', '--cfs', cfsname, '--source', src, '--destination', dst])
74
81
  print(res.stdout)
75
82
  if res.returncode != 0:
76
83
  print(f'Warning: Java subprocess returned error code {res.returncode}')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: koronascript
3
- Version: 0.1
3
+ Version: 0.2
4
4
  Summary: Wrapper around Korona modules for processing echosounder data
5
5
  Home-page: https://github.com/CRIMAC-WP4-Machine-learning/CRIMAC-KoronaScript
6
6
  Author: Ketil Malde
@@ -33,17 +33,17 @@ You need an LSSS licence. The licence have to be added according to the LSSS man
33
33
 
34
34
  ### Set system variables
35
35
 
36
- This can be set at run time either by setting the LSSS environment
36
+ The `LSSS` environment variable should point to the root directory of your
37
+ LSSS installation. It can be set at run time either by setting the LSSS environment
37
38
  variable in the shell
38
39
  ~~~
39
- export LSSS=~/lsss-2.16.0-alpha/korona
40
+ export LSSS=~/lsss-2.16.0-alpha
40
41
  ~~~
41
- before running your script, or by adding to path
42
+ before running your script, or by adding it manually from inside Python:
42
43
  ~~~
43
- lsss = '~/lsss-2.16.0-alpha/korona'
44
+ lsss = '~/lsss-2.16.0-alpha'
44
45
  os.environ["LSSS"] = lsss
45
46
  ~~~
46
- pointing at the LSSS environment to your script.
47
47
 
48
48
  # Usage
49
49
 
@@ -24,17 +24,17 @@ You need an LSSS licence. The licence have to be added according to the LSSS man
24
24
 
25
25
  ### Set system variables
26
26
 
27
- This can be set at run time either by setting the LSSS environment
27
+ The `LSSS` environment variable should point to the root directory of your
28
+ LSSS installation. It can be set at run time either by setting the LSSS environment
28
29
  variable in the shell
29
30
  ~~~
30
- export LSSS=~/lsss-2.16.0-alpha/korona
31
+ export LSSS=~/lsss-2.16.0-alpha
31
32
  ~~~
32
- before running your script, or by adding to path
33
+ before running your script, or by adding it manually from inside Python:
33
34
  ~~~
34
- lsss = '~/lsss-2.16.0-alpha/korona'
35
+ lsss = '~/lsss-2.16.0-alpha'
35
36
  os.environ["LSSS"] = lsss
36
37
  ~~~
37
- pointing at the LSSS environment to your script.
38
38
 
39
39
  # Usage
40
40
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: koronascript
3
- Version: 0.1
3
+ Version: 0.2
4
4
  Summary: Wrapper around Korona modules for processing echosounder data
5
5
  Home-page: https://github.com/CRIMAC-WP4-Machine-learning/CRIMAC-KoronaScript
6
6
  Author: Ketil Malde
@@ -33,17 +33,17 @@ You need an LSSS licence. The licence have to be added according to the LSSS man
33
33
 
34
34
  ### Set system variables
35
35
 
36
- This can be set at run time either by setting the LSSS environment
36
+ The `LSSS` environment variable should point to the root directory of your
37
+ LSSS installation. It can be set at run time either by setting the LSSS environment
37
38
  variable in the shell
38
39
  ~~~
39
- export LSSS=~/lsss-2.16.0-alpha/korona
40
+ export LSSS=~/lsss-2.16.0-alpha
40
41
  ~~~
41
- before running your script, or by adding to path
42
+ before running your script, or by adding it manually from inside Python:
42
43
  ~~~
43
- lsss = '~/lsss-2.16.0-alpha/korona'
44
+ lsss = '~/lsss-2.16.0-alpha'
44
45
  os.environ["LSSS"] = lsss
45
46
  ~~~
46
- pointing at the LSSS environment to your script.
47
47
 
48
48
  # Usage
49
49
 
@@ -1,4 +1,5 @@
1
1
  README.md
2
+ setup.cfg
2
3
  setup.py
3
4
  KoronaScript/Configuration.py
4
5
  KoronaScript/KoronaModule.py
@@ -9,4 +10,5 @@ koronascript.egg-info/PKG-INFO
9
10
  koronascript.egg-info/SOURCES.txt
10
11
  koronascript.egg-info/dependency_links.txt
11
12
  koronascript.egg-info/not-zip-safe
12
- koronascript.egg-info/top_level.txt
13
+ koronascript.egg-info/top_level.txt
14
+ tests/test_examples.py
@@ -1,3 +1,6 @@
1
+ [flake8]
2
+ ignore = E302,E501,E203
3
+
1
4
  [egg_info]
2
5
  tag_build =
3
6
  tag_date = 0
@@ -1,7 +1,7 @@
1
1
  from setuptools import setup
2
2
 
3
3
  setup(name='koronascript',
4
- version='0.1',
4
+ version='0.2',
5
5
  description='Wrapper around Korona modules for processing echosounder data',
6
6
  long_description=open('README.md').read(),
7
7
  long_description_content_type='text/markdown',
@@ -0,0 +1,15 @@
1
+ import os
2
+ import examples.channelRemoval as CR
3
+
4
+ TESTDATA = 'test_data/EK60'
5
+
6
+ def test_get_data():
7
+ if not os.path.exists(TESTDATA):
8
+ # Get test data from pyEchoLab examples:
9
+ os.system('mkdir -p test_data && cd test_data && wget --recursive --no-parent -nH --cut-dirs=6 ftp://ftp.ngdc.noaa.gov/pub/outgoing/mgg/wcd/pyEcholab_data/examples/EK60')
10
+
11
+ def test_channelRemoval():
12
+ """This fails to fail if no data is present"""
13
+ CR.ks.run('test_data/EK60', 'test_out/cr_out')
14
+
15
+
@@ -1 +0,0 @@
1
- include configuration/korona-info.json