| | 92 | ############################################################################### |
|---|
| | 93 | # Test loading complex data. |
|---|
| | 94 | |
|---|
| | 95 | def numpy_rw_3(): |
|---|
| | 96 | |
|---|
| | 97 | if gdaltest.numpy_drv is None: |
|---|
| | 98 | return 'skip' |
|---|
| | 99 | |
|---|
| | 100 | ds = gdal.Open( 'data/cint_sar.tif' ) |
|---|
| | 101 | array = ds.ReadAsArray() |
|---|
| | 102 | |
|---|
| | 103 | if array[2][3] != 116-16j: |
|---|
| | 104 | print array[0][2][3] |
|---|
| | 105 | gdaltest.post_reason( 'complex value read improperly.' ) |
|---|
| | 106 | return 'fail' |
|---|
| | 107 | |
|---|
| | 108 | return 'success' |
|---|
| | 109 | |
|---|
| | 110 | ############################################################################### |
|---|
| | 111 | # Test a band read with downsampling. |
|---|
| | 112 | |
|---|
| | 113 | def numpy_rw_4(): |
|---|
| | 114 | |
|---|
| | 115 | if gdaltest.numpy_drv is None: |
|---|
| | 116 | return 'skip' |
|---|
| | 117 | |
|---|
| | 118 | ds = gdal.Open( 'data/byte.tif' ) |
|---|
| | 119 | array = ds.GetRasterBand(1).ReadAsArray(0,0,20,20,5,5) |
|---|
| | 120 | |
|---|
| | 121 | if array[2][3] != 123: |
|---|
| | 122 | print array[2][3] |
|---|
| | 123 | gdaltest.post_reason( 'Read wrong value - perhaps downsampling algorithm has changed subtly?' ) |
|---|
| | 124 | return 'fail' |
|---|
| | 125 | |
|---|
| | 126 | return 'success' |
|---|
| | 127 | |
|---|
| | 128 | ############################################################################### |
|---|
| | 129 | # Test reading a multi-band file. |
|---|
| | 130 | |
|---|
| | 131 | def numpy_rw_5(): |
|---|
| | 132 | |
|---|
| | 133 | if gdaltest.numpy_drv is None: |
|---|
| | 134 | return 'skip' |
|---|
| | 135 | |
|---|
| | 136 | import gdalnumeric |
|---|
| | 137 | |
|---|
| | 138 | array = gdalnumeric.LoadFile('data/rgbsmall.tif',35,21,1,1) |
|---|
| | 139 | |
|---|
| | 140 | if array[0][0][0] != 78: |
|---|
| | 141 | print array |
|---|
| | 142 | gdaltest.post_reason( 'value read improperly.' ) |
|---|
| | 143 | return 'fail' |
|---|
| | 144 | |
|---|
| | 145 | if array[1][0][0] != 117: |
|---|
| | 146 | print array |
|---|
| | 147 | gdaltest.post_reason( 'value read improperly.' ) |
|---|
| | 148 | return 'fail' |
|---|
| | 149 | |
|---|
| | 150 | if array[2][0][0] != 24: |
|---|
| | 151 | print array |
|---|
| | 152 | gdaltest.post_reason( 'value read improperly.' ) |
|---|
| | 153 | return 'fail' |
|---|
| | 154 | |
|---|
| | 155 | return 'success' |
|---|