This repository was archived by the owner on Sep 1, 2022. It is now read-only.
File tree 3 files changed +22
-12
lines changed
cdm/src/main/java/ucar/nc2
3 files changed +22
-12
lines changed Original file line number Diff line number Diff line change 32
32
*/
33
33
package ucar .nc2 .dt .radial ;
34
34
35
+ import static ucar .nc2 .iosp .nexrad2 .Nexrad2IOServiceProvider .isNEXRAD2Format ;
36
+
35
37
import ucar .nc2 .*;
36
38
import ucar .nc2 .dataset .*;
37
39
import ucar .nc2 .constants .*;
@@ -67,11 +69,9 @@ public boolean isMine(NetcdfDataset ds) {
67
69
String convention = ds .findAttValueIgnoreCase (null , "Conventions" , null );
68
70
if ((null != convention ) && convention .equals (_Coordinate .Convention )) {
69
71
String format = ds .findAttValueIgnoreCase (null , "Format" , null );
70
- if (format != null && (format .equals ("ARCHIVE2" )
71
- || format .equals ("AR2V0001" ) || format .equals ("CINRAD-SA" )
72
- || format .equals ("AR2V0003" ) || format .equals ("AR2V0002" ) || format .equals ("AR2V0004" )
73
- || format .equals ("AR2V0006" ) || format .equals ("AR2V0007" )))
72
+ if (format != null && (isNEXRAD2Format (format ) || format .equals ("CINRAD-SA" ))) {
74
73
return true ;
74
+ }
75
75
}
76
76
return false ;
77
77
}
Original file line number Diff line number Diff line change @@ -144,9 +144,10 @@ public class Level2VolumeScan {
144
144
station = NexradStationDB .get (stationId );
145
145
}
146
146
147
- //see if we have to uncompress
148
- if (dataFormat .equals (AR2V0001 ) || dataFormat .equals (AR2V0003 )
149
- || dataFormat .equals (AR2V0004 ) || dataFormat .equals (AR2V0006 ) || dataFormat .equals (AR2V0007 ) ) {
147
+ // see if we have to uncompress--basically looking for anything but the original Level2 format
148
+ // technically speaking, this BZ2 compression is a detail of transmission--there's no requirement in the
149
+ // ICDs that this BZ2 block compression is actually applied on disk.
150
+ if (dataFormat .startsWith ("AR2V" )) {
150
151
raf .skipBytes (4 );
151
152
String BZ = raf .readString (2 );
152
153
if (BZ .equals ("BZ" )) {
Original file line number Diff line number Diff line change @@ -57,15 +57,24 @@ public class Nexrad2IOServiceProvider extends AbstractIOServiceProvider {
57
57
static private final int MISSING_INT = -9999 ;
58
58
static private final float MISSING_FLOAT = Float .NaN ;
59
59
60
+ public static boolean isNEXRAD2Format (String format ) {
61
+ return isNEXRAD2Format (format , false );
62
+ }
63
+
64
+ private static boolean isNEXRAD2Format (String format , boolean checkIfKnown ) {
65
+ if (format != null && (format .equals ("ARCHIVE2" ) || format .startsWith ("AR2V" ))) {
66
+ if (checkIfKnown && format .startsWith ("AR2V" ) && Integer .parseInt (format .substring (4 )) > 8 ) {
67
+ logger .warn ("Trying to handle unknown but valid-looking format: " + format );
68
+ }
69
+ return true ;
70
+ }
71
+ return false ;
72
+ }
60
73
61
74
public boolean isValidFile ( RandomAccessFile raf ) throws IOException {
62
75
try {
63
76
raf .seek (0 );
64
- String test = raf .readString (8 );
65
- return test .equals ( Level2VolumeScan .ARCHIVE2 ) || test .equals ( Level2VolumeScan .AR2V0001 ) ||
66
- test .equals ( Level2VolumeScan .AR2V0003 )|| test .equals ( Level2VolumeScan .AR2V0004 ) ||
67
- test .equals ( Level2VolumeScan .AR2V0002 ) || test .equals ( Level2VolumeScan .AR2V0006 ) ||
68
- test .equals ( Level2VolumeScan .AR2V0007 );
77
+ return isNEXRAD2Format (raf .readString (8 ));
69
78
} catch (IOException ioe ) {
70
79
return false ;
71
80
}
You can’t perform that action at this time.
0 commit comments