Skip to content

Commit

Permalink
Thu Feb 22 16:30:45 MST 2018
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Buscombe committed Feb 22, 2018
1 parent 2298d6a commit c010e54
Show file tree
Hide file tree
Showing 29 changed files with 130 additions and 125 deletions.
20 changes: 9 additions & 11 deletions MANIFEST
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
# file GENERATED by distutils, do NOT edit
LICENSE
README.md
setup.cfg
setup.py
data/newbex/bs/mosaic_100.tiff
data/newbex/bs/mosaic_200.tiff
data/newbex/bs/mosaic_400.tiff
data/newbex/ref/newbex_bed.cpg
data/newbex/ref/newbex_bed.dbf
data/newbex/ref/newbex_bed.prj
data/newbex/ref/newbex_bed.qpj
data/newbex/ref/newbex_bed.shp
data/newbex/ref/newbex_bed.shx
prism/__init__.py
prism/common_funcs.py
prism/crf_funcs.py
prism/eval_funcs.py
prism/gmm_funcs.py
prism/gui_funcs.py
prism/newbex_bed.cpg
prism/newbex_bed.dbf
prism/newbex_bed.prj
prism/newbex_bed.qpj
prism/newbex_bed.shp
prism/newbex_bed.shx
prism/newbex_mosaic_100.tiff
prism/newbex_mosaic_200.tiff
prism/newbex_mosaic_400.tiff
prism/plot_funcs.py
prism/prism_logo_blk_sm.png
prism/read_funcs.py
Expand Down
5 changes: 0 additions & 5 deletions MANIFEST.in

This file was deleted.

7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@ A Python framework for Probabilistic Acoustic Sediment Mapping. See project webs


### Contributing & Credits
Primary Developer: Daniel Buscombe, Northern Arizona University, Flagstaff, AZ 86011, [email protected]
Software Developer: Dr. Daniel Buscombe, Northern Arizona University, Flagstaff, AZ 86011, [email protected]

Example backscatter data (.tiff files) originate from data collected by R2Sonic and distributed for use as part of the R2Sonic 2017 Multispectral Backscatter competition.

Bed observation data from Patricia Bay are digitized from data presented in: B.~Biffard. Seabed remote sensing by single-beam echosounder: models, methods and applications. Doctoral dissertation, University of Victoria, Canada, 2011.

Bed observation data from Portsmouth (NEWBEX) are digitized from data presented in: T.~Weber, L.~and Ward. Observations of backscatter from sand and gravel seafloors between 170 and 250 kHz. Journal of the Acoustical Society of America, vol.~138, no.~4, pp.~2169 - 2180, 2015.
Binary file removed data/bedford2016/bs/mosaic_100.tiff
Binary file not shown.
Binary file removed data/bedford2016/bs/mosaic_200.tiff
Binary file not shown.
Binary file removed data/bedford2016/bs/mosaic_400.tiff
Binary file not shown.
28 changes: 0 additions & 28 deletions data/bedford2016/ref/X_y_ID_label.csv

This file was deleted.

Binary file removed data/bedford2017/bs/mosaic_100.tiff
Binary file not shown.
Binary file removed data/bedford2017/bs/mosaic_200.tiff
Binary file not shown.
Binary file removed data/bedford2017/bs/mosaic_400.tiff
Binary file not shown.
28 changes: 0 additions & 28 deletions data/bedford2017/ref/X_y_ID_label.csv

This file was deleted.

20 changes: 0 additions & 20 deletions data/newbex/bs/mosaic_100.tiff.aux.xml

This file was deleted.

22 changes: 20 additions & 2 deletions prism/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
# encoding: utf-8
# ____ ____ ___ ____ __ __
# | _ \| _ \|_ _/ ___|| \/ | _
# | |_) | |_) || |\___ \| |\/| | (_)
# | __/| _ < | | ___) | | | | _
# |_| |_| \_\___|____/|_| |_| (_)
#
# ___ _ _ __ __
# | _ _ ||_ _ \/ _|__ ._ |_).__ |_ _.|_ o|o(__|_o _ /\ _ _ (__|_o _
# |(_)(_)||_)(_)/\ |(_)| | |(_)|_)(_||_)|||__)|_|(_ /--\(_(_)|_|__)|_|(_
#
# __
# (_ _ _|o._ _ _ .__|_ |\/| _.._ ._ o._ _
# __)(/_(_||| | |(/_| ||_ | |(_||_)|_)|| |(_|
# | | _|
#
# |b|y| |D|a|n|i|e|l| |B|u|s|c|o|m|b|e|
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
# |d|a|n|i|e|l|.|b|u|s|c|o|m|b|e|@|n|a|u|.|e|d|u|

__version__ = '0.0.15'
__version__ = '0.0.19'

#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
__all__ = ['common_funcs', 'crf_funcs', 'gmm_funcs', 'read_funcs',
'write_funcs', 'eval_funcs', 'gui_funcs'] #, 'test']
'write_funcs', 'eval_funcs', 'gui_funcs', 'test']

from . import common_funcs
from . import crf_funcs
Expand Down
6 changes: 4 additions & 2 deletions prism/eval_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def plot_confmatGMM(y_pred, Lc, bed, prefix):
This function ...
"""

base = '..'+os.sep+'outputs'+os.sep+prefix+'_'
#base = '..'+os.sep+'outputs'+os.sep+prefix+'_'
base = prefix+'_'

y = y_pred.copy()
del y_pred
Expand Down Expand Up @@ -114,7 +115,8 @@ def plot_confmatCRF(y_pred, Lc, bed, prefix):
This function ...
"""

base = '..'+os.sep+'outputs'+os.sep+prefix+'_'
#base = '..'+os.sep+'outputs'+os.sep+prefix+'_'
base = prefix+'_'

y = y_pred.copy()
del y_pred
Expand Down
5 changes: 3 additions & 2 deletions prism/gui_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
from PIL import Image, ImageTk

# prism functions
import prism
from prism.common_funcs import *
from prism.crf_funcs import *
from prism.gmm_funcs import *
Expand Down Expand Up @@ -144,8 +145,8 @@ def gui():
image_panel.grid(column = 0, row = 2)
image_panel.configure(background='black')

#show_image = ImageTk.PhotoImage(Image.open(prism.__path__[0]+os.sep+"prism_logo_blk.png"))
show_image = ImageTk.PhotoImage(Image.open("prism_logo_blk_sm.png"))
show_image = ImageTk.PhotoImage(Image.open(prism.__path__[0]+os.sep+"prism_logo_blk_sm.png"))
#show_image = ImageTk.PhotoImage(Image.open("prism_logo_blk_sm.png"))
# show the panel
image_panel.create_image(0, 0, anchor=Tkinter.NW, image=show_image)

Expand Down
1 change: 1 addition & 0 deletions prism/newbex_bed.cpg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UTF-8
Binary file added prism/newbex_bed.dbf
Binary file not shown.
1 change: 1 addition & 0 deletions prism/newbex_bed.prj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
1 change: 1 addition & 0 deletions prism/newbex_bed.qpj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]
Binary file added prism/newbex_bed.shp
Binary file not shown.
Binary file added prism/newbex_bed.shx
Binary file not shown.
Binary file added prism/newbex_mosaic_100.tiff
Binary file not shown.
Binary file added prism/newbex_mosaic_200.tiff
Binary file not shown.
Binary file added prism/newbex_mosaic_400.tiff
Binary file not shown.
24 changes: 16 additions & 8 deletions prism/plot_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def plot_bs_maps(img, bed, bs, cmap, prefix):
latmin = bs[0]['latmin']
latmax = bs[0]['latmax']

base = '..'+os.sep+'outputs'+os.sep+prefix+'_'
#base = '..'+os.sep+'outputs'+os.sep+prefix+'_'
base = prefix+'_'

cmap = colors.ListedColormap(cmap)

Expand Down Expand Up @@ -261,7 +262,8 @@ def plot_dists_per_sed(Lc, img, bed, cmap, prefix):
This function ...
"""

base = '..'+os.sep+'outputs'+os.sep+prefix+'_'
#base = '..'+os.sep+'outputs'+os.sep+prefix+'_'
base = prefix+'_'

cmap = colors.ListedColormap(cmap)

Expand Down Expand Up @@ -363,7 +365,8 @@ def plot_gmm(mask, y_pred, y_prob, bs, bed, cmap, prefix):
latmin = bs[0]['latmin']
latmax = bs[0]['latmax']

base = '..'+os.sep+'outputs'+os.sep+prefix+'_'
#base = '..'+os.sep+'outputs'+os.sep+prefix+'_'
base = prefix+'_'

#----------------------------------------------------------------

Expand Down Expand Up @@ -465,7 +468,8 @@ def plot_gmm_image(mask, y_pred, y_prob, bs, bed, cmap, prefix):

cmap = colors.ListedColormap(cmap)

base = '..'+os.sep+'outputs'+os.sep+prefix+'_'
#base = '..'+os.sep+'outputs'+os.sep+prefix+'_'
base = prefix+'_'

#----------------------------------------------------------------
X = bed['Xlon']
Expand Down Expand Up @@ -584,7 +588,8 @@ def plot_crf(mask, y_pred, y_prob, bs, bed, cmap, prefix):
y_prob[mask==1] = np.nan
y_pred[mask==1] = np.nan

base = '..'+os.sep+'outputs'+os.sep+prefix+'_'
#base = '..'+os.sep+'outputs'+os.sep+prefix+'_'
base = prefix+'_'

cmap = colors.ListedColormap(cmap)

Expand Down Expand Up @@ -690,7 +695,8 @@ def plot_crf_image(mask, y_pred, y_prob, bs, bed, cmap, prefix):
y_prob[mask==1] = np.nan
y_pred[mask==1] = np.nan

base = '..'+os.sep+'outputs'+os.sep+prefix+'_'
#base = '..'+os.sep+'outputs'+os.sep+prefix+'_'
base = prefix+'_'

cmap = colors.ListedColormap(cmap)

Expand Down Expand Up @@ -819,7 +825,8 @@ def plot_gmm_crf(mask, y_pred_gmm, y_prob_gmm, y_pred_crf, y_prob_crf, bs, bed,
latmin = bs[0]['latmin']
latmax = bs[0]['latmax']

base = '..'+os.sep+'outputs'+os.sep+prefix+'_'
#base = '..'+os.sep+'outputs'+os.sep+prefix+'_'
base = prefix+'_'

#----------------------------------------------------------------

Expand Down Expand Up @@ -999,7 +1006,8 @@ def plot_gmm_crf_images(mask, y_pred_gmm, y_prob_gmm, y_pred_crf, y_prob_crf, bs
y_prob_crf[mask==1] = np.nan
y_pred_crf[mask==1] = np.nan

base = '..'+os.sep+'outputs'+os.sep+prefix+'_'
#base = '..'+os.sep+'outputs'+os.sep+prefix+'_'
base = prefix+'_'

cmap = colors.ListedColormap(cmap)

Expand Down
39 changes: 35 additions & 4 deletions prism/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import os

# prism functions
import prism
from prism.common_funcs import *
from prism.crf_funcs import *
from prism.gmm_funcs import *
Expand All @@ -37,10 +38,34 @@
from prism.eval_funcs import *
from prism.plot_funcs import *

import os
import shutil
import errno

def dircopy(src, dest):
try:
shutil.copytree(src, dest)
except OSError as e:
# If the error was caused because the source wasn't a directory
if e.errno == errno.ENOTDIR:
shutil.copy(src, dest)
else:
print('Directory not copied. Error: %s' % e)

__all__ = [
'dotest',
]

##-------------------------------------------------------------

def dotest():


# copy files over to somewhere read/writeable
dircopy(prism.__path__[0], os.path.expanduser("~")+os.sep+'prism_test')

# general settings

##GMM parameters
covariance = 'full'
tol = 1e-2
Expand All @@ -57,10 +82,16 @@ def dotest():
prob_thres = 0.1
chambolle = 0.0
test_size = 0.5
bs100 = '..'+os.sep+'data'+os.sep+'newbex'+os.sep+'bs'+os.sep+'mosaic_100.tiff'
bs200 = '..'+os.sep+'data'+os.sep+'newbex'+os.sep+'bs'+os.sep+'mosaic_200.tiff'
bs400 = '..'+os.sep+'data'+os.sep+'newbex'+os.sep+'bs'+os.sep+'mosaic_400.tiff'
refs_file = '..'+os.sep+'data'+os.sep+'newbex'+os.sep+'ref'+os.sep+'newbex_bed.shp'

bs100 = os.path.normpath(os.path.join(os.path.expanduser("~"),'prism_test','newbex_mosaic_100.tiff'))
bs200 = os.path.normpath(os.path.join(os.path.expanduser("~"),'prism_test','newbex_mosaic_200.tiff'))
bs400 = os.path.normpath(os.path.join(os.path.expanduser("~"),'prism_test','newbex_mosaic_400.tiff'))
refs_file = os.path.normpath(os.path.join(os.path.expanduser("~"),'prism_test','newbex_bed.shp'))

#bs100 = '..'+os.sep+'data'+os.sep+'newbex'+os.sep+'bs'+os.sep+'mosaic_100.tiff'
#bs200 = '..'+os.sep+'data'+os.sep+'newbex'+os.sep+'bs'+os.sep+'mosaic_200.tiff'
#bs400 = '..'+os.sep+'data'+os.sep+'newbex'+os.sep+'bs'+os.sep+'mosaic_400.tiff'
#refs_file = '..'+os.sep+'data'+os.sep+'newbex'+os.sep+'ref'+os.sep+'newbex_bed.shp'
prefix = 'newbex'

input = [bs100, bs200, bs400]
Expand Down
17 changes: 14 additions & 3 deletions prism/write_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def export_bed_data(bed, prefix):
This function ...
"""

base = '..'+os.sep+'outputs'+os.sep+prefix+'_'
#base = '..'+os.sep+'outputs'+os.sep+prefix+'_'
base = prefix+'_'

rows = zip(bed['Xlon'], bed['Ylat'], bed['Cnames'], bed['Ccodes'])

Expand All @@ -55,6 +56,14 @@ def export_bed_data(bed, prefix):
'geometry': mapping(point)
})

# create the .prj file
prj = open(base+'bed_observations.prj', "w")
# call the function and supply the epsg code
epsg = 'GEOGCS["WGS84",DATUM["WGS_1984",SPHEROID["WGS84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]'
prj.write(epsg)
prj.close()


##-------------------------------------------------------------
def export_crf_gtiff(mask, y_pred, y_prob, bs, prefix):
"""
Expand All @@ -68,7 +77,8 @@ def export_crf_gtiff(mask, y_pred, y_prob, bs, prefix):
prob[mask==1] = np.nan
pred[mask==1] = np.nan

base = '..'+os.sep+'outputs'+os.sep+prefix+'_'
#base = '..'+os.sep+'outputs'+os.sep+prefix+'_'
base = prefix+'_'

proj = osr.SpatialReference()
proj.ImportFromEPSG(4326)
Expand Down Expand Up @@ -137,7 +147,8 @@ def export_gmm_gtiff(mask, y_pred, y_prob, bs, prefix):
prob[mask==1] = np.nan
pred[mask==1] = np.nan

base = '..'+os.sep+'outputs'+os.sep+prefix+'_'
#base = '..'+os.sep+'outputs'+os.sep+prefix+'_'
base = prefix+'_'

proj = osr.SpatialReference()
proj.ImportFromEPSG(4326)
Expand Down
Loading

0 comments on commit c010e54

Please sign in to comment.