Skip to content
Browse files

Removed ubyte_filter and uint16_filter, they are replaced by

convert_to_data_type in the dtype.py module.
  • Loading branch information...
1 parent 633ad43 commit 93570a9aa093349381850822d07742aca7b4c8c0 @davidh-ssec committed Dec 30, 2012
View
7 py/polar2grid/polar2grid/awips/awips_netcdf.py
@@ -48,9 +48,10 @@
from polar2grid.core import Workspace
from polar2grid.core import roles
-from polar2grid.core.constants import DEFAULT_FILL_VALUE
+from polar2grid.core.constants import *
from polar2grid.nc import create_nc_from_ncml
-from polar2grid.core.rescale import Rescaler,ubyte_filter
+from polar2grid.core.rescale import Rescaler
+from polar2grid.core.dtype import clip_to_data_type
from .awips_config import get_awips_info,load_config as load_awips_config,can_handle_inputs as config_can_handle_inputs
import os, sys, logging, re
@@ -94,7 +95,7 @@ def create_netcdf(nc_name, image, template, start_dt,
raise ValueError("Image shapes aren't equal, expected %s got %s" % (str(image_var.shape),str(image.shape)))
# Convert to signed byte keeping large values large
- image = ubyte_filter(image)
+ image = clip_to_data_type(image, DTYPE_UINT8)
image_var[:] = image
time_var = nc.variables["validTime"]
View
8 py/polar2grid/polar2grid/gtiff_backend.py
@@ -15,10 +15,10 @@
from osgeo import gdal
import osr
-from polar2grid.core.rescale import Rescaler,uint16_filter,ubyte_filter
+from polar2grid.core.rescale import Rescaler
from polar2grid.core.constants import *
from polar2grid.core import roles
-from polar2grid.core.dtype import str_to_dtype
+from polar2grid.core.dtype import str_to_dtype,clip_to_data_type
import sys
import logging
@@ -103,9 +103,9 @@ def create_geotiff(data, output_filename, proj4_str, geotransform,
# do a linear scaling. No one should be scaling data to outside these
# ranges anyway
if etype == gdal.GDT_UInt16:
- band_data = uint16_filter(band_data)
+ band_data = clip_to_data_type(band_data, DTYPE_UINT16)
elif etype == gdal.GDT_Byte:
- band_data = ubyte_filter(band_data)
+ band_data = clip_to_data_type(band_data, DTYPE_UINT8)
if log_level <= logging.DEBUG:
log.debug("Data min: %f, max: %f" % (band_data.min(),band_data.max()))
View
16 py/polar2grid_core/polar2grid/core/rescale.py
@@ -45,22 +45,6 @@ def linear_scale(img, fill_in=DEFAULT_FILL_IN, fill_out=DEFAULT_FILL_OUT):
return img
return linear_scale
-def ubyte_filter(img):
- """Convert image data to a numpy array with dtype `numpy.uint8` and set
- values below zero to zero and values above 255 to 255.
- """
- numpy.clip(img, 0, 255, out=img)
- img = img.astype(numpy.uint8)
- return img
-
-def uint16_filter(img):
- """Convert image data to a numpy array with dtype `numpy.uint16` and set
- values below zero to zero and values above 65535 to 65535.
- """
- numpy.clip(img, 0, 65535, out=img)
- img = img.astype(numpy.uint16)
- return img
-
def linear_scale(img, m, b, fill_in=DEFAULT_FILL_IN, fill_out=DEFAULT_FILL_OUT):
log.debug("Running 'linear_scale' with (m: %f, b: %f)..." % (m,b))

0 comments on commit 93570a9

Please sign in to comment.
Something went wrong with that request. Please try again.