Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
goesr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ray Garcia
goesr
Commits
f77a70b8
Commit
f77a70b8
authored
8 years ago
by
Ray Garcia
Browse files
Options
Downloads
Patches
Plain Diff
failed experiment adding BT colors
parent
ada75c9e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
goesr/rad_count_dist.py
+25
-7
25 additions, 7 deletions
goesr/rad_count_dist.py
with
25 additions
and
7 deletions
goesr/rad_count_dist.py
+
25
−
7
View file @
f77a70b8
...
@@ -9,15 +9,19 @@ Recommended runtime: Python 3.6 with netCDF4, numba, numpy, e.g. Continuum.IO An
...
@@ -9,15 +9,19 @@ Recommended runtime: Python 3.6 with netCDF4, numba, numpy, e.g. Continuum.IO An
import
netCDF4
as
nc4
import
netCDF4
as
nc4
import
numpy
as
np
import
numpy
as
np
import
numba
import
numba
try
:
import
goesr.l1b
as
pug
except
:
pug
=
None
def
load
(
ncfilename
,
varname
):
def
load
(
nc
,
varname
):
nc
=
nc4
.
Dataset
(
ncfilename
)
nc
.
set_auto_scale
(
False
)
nc
.
set_auto_scale
(
False
)
ncv
=
nc
[
varname
]
ncv
=
nc
[
varname
]
counts
=
ncv
[:]
counts
=
ncv
[:]
bit_depth
=
ncv
.
sensor_band_bit_depth
bit_depth
=
ncv
.
sensor_band_bit_depth
print
(
"
{}: bit depth {},
"
)
splat
=
counts
.
ravel
()
splat
=
counts
.
ravel
()
return
splat
,
bit_depth
return
splat
,
bit_depth
,
ncv
.
scale_factor
,
ncv
.
add_offset
@numba.jit
((
numba
.
int16
[:],
numba
.
int32
))
@numba.jit
((
numba
.
int16
[:],
numba
.
int32
))
def
dist
(
splat
,
bit_depth
):
def
dist
(
splat
,
bit_depth
):
...
@@ -26,7 +30,7 @@ def dist(splat, bit_depth):
...
@@ -26,7 +30,7 @@ def dist(splat, bit_depth):
z
[
v
]
+=
1
z
[
v
]
+=
1
return
z
return
z
def
hist
(
pngname
,
filename
,
distribution
,
extra
=
''
):
def
hist
(
pngname
,
filename
,
distribution
,
bt
=
None
,
extra
=
''
):
import
matplotlib
import
matplotlib
matplotlib
.
use
(
'
Agg
'
)
matplotlib
.
use
(
'
Agg
'
)
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
...
@@ -34,7 +38,11 @@ def hist(pngname, filename, distribution, extra=''):
...
@@ -34,7 +38,11 @@ def hist(pngname, filename, distribution, extra=''):
ax
=
fig
.
add_subplot
(
111
)
#, axisbg='#EEEEEE')
ax
=
fig
.
add_subplot
(
111
)
#, axisbg='#EEEEEE')
# ax.grid(color='white', linestyle='solid')
# ax.grid(color='white', linestyle='solid')
ax
.
grid
()
ax
.
grid
()
ax
.
plot
(
np
.
log
(
distribution
+
1
),
'
.
'
)
if
bt
is
None
:
ax
.
plot
(
np
.
log
(
distribution
+
1
),
'
.
'
)
else
:
sc
=
ax
.
scatter
(
np
.
arange
(
len
(
distribution
.
squeeze
())),
distribution
,
c
=
bt
)
plt
.
colorbar
(
sc
)
ax
.
set_xlabel
(
'
unscaled pixel value
'
)
ax
.
set_xlabel
(
'
unscaled pixel value
'
)
ax
.
set_ylabel
(
'
log(occurrences+1)
'
)
ax
.
set_ylabel
(
'
log(occurrences+1)
'
)
ax
.
set_title
(
'
log(n+1) {} value distribution
'
.
format
(
filename
)
+
extra
)
ax
.
set_title
(
'
log(n+1) {} value distribution
'
.
format
(
filename
)
+
extra
)
...
@@ -45,9 +53,11 @@ if __name__=='__main__':
...
@@ -45,9 +53,11 @@ if __name__=='__main__':
if
len
(
sys
.
argv
)
==
1
:
if
len
(
sys
.
argv
)
==
1
:
print
(
"
parameters: netcdf-filename counts-variable-name optional-histogram optional-histogram-bins
"
)
print
(
"
parameters: netcdf-filename counts-variable-name optional-histogram optional-histogram-bins
"
)
ncfilename
,
varname
=
sys
.
argv
[
1
:
3
]
ncfilename
,
varname
=
sys
.
argv
[
1
:
3
]
splat
,
bit_depth
=
load
(
ncfilename
,
varname
)
nc
=
nc4
.
Dataset
(
ncfilename
)
splat
,
bit_depth
,
sf
,
ao
=
load
(
nc
,
varname
)
distribution
=
dist
(
splat
,
bit_depth
)
distribution
=
dist
(
splat
,
bit_depth
)
uniq
=
np
.
argwhere
(
distribution
!=
0
).
squeeze
()
uniq
=
np
.
argwhere
(
distribution
!=
0
).
squeeze
()
minv
,
maxv
=
np
.
min
(
uniq
),
np
.
max
(
uniq
)
fn
=
os
.
path
.
split
(
ncfilename
)[
-
1
]
fn
=
os
.
path
.
split
(
ncfilename
)[
-
1
]
nvals
=
len
(
uniq
)
nvals
=
len
(
uniq
)
print
(
"
{} of {} unique values in {}
"
.
format
(
nvals
,
2
**
bit_depth
,
fn
))
print
(
"
{} of {} unique values in {}
"
.
format
(
nvals
,
2
**
bit_depth
,
fn
))
...
@@ -55,4 +65,12 @@ if __name__=='__main__':
...
@@ -55,4 +65,12 @@ if __name__=='__main__':
stem
=
sys
.
argv
[
3
]
stem
=
sys
.
argv
[
3
]
with
open
(
stem
+
'
.tsv
'
,
'
wt
'
)
as
fp
:
with
open
(
stem
+
'
.tsv
'
,
'
wt
'
)
as
fp
:
fp
.
write
(
'
\n
'
.
join
([
'
{}
\t
{}
'
.
format
(
i
,
x
)
for
i
,
x
in
enumerate
(
distribution
)])
+
'
\n
'
)
fp
.
write
(
'
\n
'
.
join
([
'
{}
\t
{}
'
.
format
(
i
,
x
)
for
i
,
x
in
enumerate
(
distribution
)])
+
'
\n
'
)
hist
(
stem
+
'
.png
'
,
fn
,
distribution
,
'
{} unique values of {}
'
.
format
(
nvals
,
2
**
bit_depth
))
if
pug
is
None
:
bt
=
None
else
:
l1b
=
pug
.
PugL1bTools
(
nc
)
# radiance range
r
=
np
.
arange
(
2
**
bit_depth
,
dtype
=
np
.
float32
).
reshape
((
1
,
2
**
bit_depth
))
*
sf
+
ao
bt
=
pug
.
calc_bt
(
r
,
**
l1b
.
cal
)
bt
=
bt
.
squeeze
()
hist
(
stem
+
'
.png
'
,
fn
,
distribution
,
bt
,
'
{} unique values of {} range {} {}
'
.
format
(
nvals
,
2
**
bit_depth
,
minv
,
maxv
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment