-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathpds2tifbatch
More file actions
executable file
·77 lines (64 loc) · 1.56 KB
/
pds2tifbatch
File metadata and controls
executable file
·77 lines (64 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
. ~/initcass.sh
function get_min_from_cub() {
cub=$1
stats from=$cub | grep '^ Minimum' | cut -d = -f 2 | awk '{$1=$1};1'
}
function get_max_from_cub() {
cub=$1
stats from=$cub | grep '^ Maximum' | cut -d = -f 2 | awk '{$1=$1};1'
}
function min() {
if [ `bc <<< "$1 <= $2"` -eq 1 ]; then
echo $1
else
echo $2
fi
}
function max() {
if [ `bc <<< "$1 >= $2"` -eq 1 ]; then
echo $1
else
echo $2
fi
}
function get_min_max_for_channel() {
channel=$1
data_min=999999
data_max=0
for f in `ls *cub`; do
mn=`get_min_from_cub $f+$channel`
mx=`get_max_from_cub $f+$channel`
data_min=`min $data_min $mn`
data_max=`max $data_max $mx`
done
echo $data_min $data_max
}
function get_total_min_max() {
data_min=999999
data_max=0
for c in 1 2 3; do
mn_mx=`get_min_max_for_channel $c`
mn=`echo $mn_mx | cut -d ' ' -f 1`
mx=`echo $mn_mx | cut -d ' ' -f 2`
data_min=`min $data_min $mn`
data_max=`max $data_max $mx`
done
echo $data_min $data_max
}
# Convert all PDS files into cube
for f in `ls *lbl`; do
lblfile=$f
basefile="${lblfile%.*}"
pds2isis from=$lblfile to=$basefile.cub
done
mn_mx=`get_total_min_max`
mn=`echo $mn_mx | cut -d ' ' -f 1`
mx=`echo $mn_mx | cut -d ' ' -f 2`
# Convert all cube files to tifs
for f in `ls *lbl`; do
lblfile=$f
basefile="${lblfile%.*}"
isis2std red=$basefile.cub+1 green=$basefile.cub+2 blue=$basefile.cub+3 to=$basefile.tif mode=rgb\
format=tiff bittype=u16bit stretch=manual rmin=$mn rmax=$mx gmin=$mn gmax=$mx bmin=$mn bmax=$mx
done