diff --git a/autotest/gdrivers/derived.py b/autotest/gdrivers/derived.py index 34e5f13e1156..770b3cd3bb5d 100755 --- a/autotest/gdrivers/derived.py +++ b/autotest/gdrivers/derived.py @@ -39,7 +39,7 @@ # Test opening a L1C product -def derived_test(): +def derived_test1(): filename = "data/cfloat64.tif" gdal.ErrorReset() ds = gdal.Open(filename) @@ -47,7 +47,8 @@ def derived_test(): gdaltest.post_reason('fail') return 'fail' got_dsds = ds.GetMetadata('DERIVED_SUBDATASETS') - + expected_gt = ds.GetGeoTransform() + expected_prj = ds.GetProjection() expected_dsds = {'DERIVED_SUBDATASET_0_NAME' : 'DERIVED_SUBDATASET:AMPLITUDE:data/cfloat64.tif', 'DERIVED_SUBDATASET_0_DESC' : 'Amplitude of input bands from data/cfloat64.tif', 'DERIVED_SUBDATASET_1_NAME' : 'DERIVED_SUBDATASET:PHASE:data/cfloat64.tif', @@ -69,19 +70,81 @@ def derived_test(): pprint.pprint(got_dsds) return 'fail' - for (key,val) in expected_dsds.iteritems(): if key.endswith('_NAME'): ds = gdal.Open(val) if ds is None or gdal.GetLastErrorMsg() != '': gdaltest.post_reason('fail') return 'fail' - + gt = ds.GetGeoTransform() + if gt != expected_gt: + gdaltest.post_reason('fail') + import pprint + pprint.pprint("Expected geotransform: "+str(expected_gt)+", got "+str(gt)) + return 'fail' + prj = ds.GetProjection() + if prj != expected_prj: + gdaltest.post_reason('fail') + import pprint + pprint.pprint("Expected projection: "+str(expected_prj)+", got: "+str(gt)) + return 'fail' return 'success' +def derived_test2(): + filename = "data/cint_sar.tif" + gdal.ErrorReset() + ds = gdal.Open(filename) + if ds is None or gdal.GetLastErrorMsg() != '': + gdaltest.post_reason('fail') + return 'fail' + got_dsds = ds.GetMetadata('DERIVED_SUBDATASETS') + expected_dsds = {'DERIVED_SUBDATASET_0_NAME' : 'DERIVED_SUBDATASET:AMPLITUDE:data/cint_sar.tif', + 'DERIVED_SUBDATASET_0_DESC' : 'Amplitude of input bands from data/cint_sar.tif', + 'DERIVED_SUBDATASET_1_NAME' : 'DERIVED_SUBDATASET:PHASE:data/cint_sar.tif', + 'DERIVED_SUBDATASET_1_DESC' : 'Phase of input bands from data/cint_sar.tif', + 'DERIVED_SUBDATASET_2_NAME' : 'DERIVED_SUBDATASET:REAL:data/cint_sar.tif', + 'DERIVED_SUBDATASET_2_DESC' : 'Real part of input bands from data/cint_sar.tif', + 'DERIVED_SUBDATASET_3_NAME' : 'DERIVED_SUBDATASET:IMAG:data/cint_sar.tif', + 'DERIVED_SUBDATASET_3_DESC' : 'Imaginary part of input bands from data/cint_sar.tif', + 'DERIVED_SUBDATASET_4_NAME' : 'DERIVED_SUBDATASET:CONJ:data/cint_sar.tif', + 'DERIVED_SUBDATASET_4_DESC' : 'Conjugate of input bands from data/cint_sar.tif', + 'DERIVED_SUBDATASET_5_NAME' : 'DERIVED_SUBDATASET:INTENSITY:data/cint_sar.tif', + 'DERIVED_SUBDATASET_5_DESC' : 'Intensity (squared amplitude) of input bands from data/cint_sar.tif', + 'DERIVED_SUBDATASET_6_NAME' : 'DERIVED_SUBDATASET:LOGAMPLITUDE:data/cint_sar.tif', + 'DERIVED_SUBDATASET_6_DESC' : 'log10 of amplitude of input bands from data/cint_sar.tif'} + + expected_cs = { 'DERIVED_SUBDATASET_0_NAME' : 345, + 'DERIVED_SUBDATASET_5_NAME' : 314, + 'DERIVED_SUBDATASET_3_NAME' : 142, + 'DERIVED_SUBDATASET_1_NAME' : 10, + 'DERIVED_SUBDATASET_6_NAME' : 99, + 'DERIVED_SUBDATASET_4_NAME' : 110, + 'DERIVED_SUBDATASET_2_NAME' : 159} + + if got_dsds != expected_dsds: + gdaltest.post_reason('fail') + import pprint + pprint.pprint(got_dsds) + return 'fail' + + for (key,val) in expected_dsds.iteritems(): + if key.endswith('_NAME'): + ds = gdal.Open(val) + if ds is None or gdal.GetLastErrorMsg() != '': + gdaltest.post_reason('fail') + return 'fail' + cs = ds.GetRasterBand(1).Checksum() + if expected_cs[key] != cs: + gdaltest.post_reason('fail') + import pprint + pprint.pprint("Expected checksum "+str(expected_cs[key])+", got "+str(cs)) + return 'fail' + + return 'success' gdaltest_list = [ - derived_test + derived_test1, + derived_test2 ] if __name__ == '__main__':