I have the same error from the OSGEO4W window... It may be that it's a problem with the setup of the environment, something about a library missing when I delve into it:
from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT
However, in a normal command window it works just fine.. I have added GDAL_DATA and other environment variables which are important to get GDAL working in python and I'm using python 2.7 (that came with ArcMap).
Environments variables that GDAL uses:
GDAL_DATA C:\Program Files\QGIS Dufour\share\gdal
GDAL_DRIVER_PATH C:\Program Files\QGIS Dufour\bin\gdalplugins
GEOTIFF_CSV C:\Program Files\QGIS Dufour\share\epsg_csv
PROJ_LIB C:\Program Files\QGIS Dufour\share\proj
You will have to find these folders in your local system, they should be fairly close.
To automate save your list of python commands with the extension ".bat" and double click. If you aren't comfortable with permanently setting your environment variables then use a format like this:
set GDAL_DATA=C:\Program Files\QGIS Dufour\share\gdal
set GDAL_DRIVER_PATH=C:\Program Files\QGIS Dufour\bin\gdalplugins
set GEOTIFF_CSV=C:\Program Files\QGIS Dufour\share\epsg_csv
set PROJ_LIB=C:\Program Files\QGIS Dufour\share\proj
gdal_calc.py -A 2000025-2000032.s0481pfv50-sst-16b.hdf.tiff_C.tiff -B C:\temp\QUAL\2000025-2000032.m0481pfv50-qual.hdf.tiffBINARY.tiff --outfile=A25_32_SSTQUAL4.tiff --calc="A*B"
pause
When saved as a batch file (.bat) and double clicked it will open a command window, run the command and then prompt the user to press enter to continue (exit). The environment settings are not permanent when done this way and only apply to that window. If you are concerned about which version of python is running the code then use set path=<your python path>;%path%
to limit the path to just the one version.
In a batch file %A is replaced by %%A, the command processor removes the first %:
set GDAL_DATA=C:\Program Files\QGIS Valmiera\share\gdal
set GDAL_DRIVER_PATH=C:\Program Files\QGIS Valmiera\bin\gdalplugins
set GEOTIFF_CSV=C:\Program Files\QGIS Valmiera\share\epsg_csv
set PROJ_LIB=C:\Program Files\QGIS Valmiera\share\proj
pause
for %%A in ("C:\temp\*.hdf") do gdal_translate -of GTiff -a_srs "+init=epsg:4326" -a_ullr -180 90 180 -90 -co "COMPRESS=PACKBITS" -sds "%%A" "%%A.tiff"
for %%A in ("C:\temp\*.tiff") do gdalinfo "%%A" >>"%%A.txt"
for %%A in ("C:\temp\*.tiff") do gdal_calc.py -A "%%A" --outfile="%%ABINARY.tiff" --calc="0*(A<3)" --calc="1*(A>3)"
for %%A in ("C:\temp\*.tiff") do gdal_calc.py -A "%%A" --outfile="%%A_C.tiff" --calc="A*(0.07500000298)"
gdal_calc.py -A 2000001-2000008.s0481pfv50-sst-16b.hdf.tiff_C.tiff -B C:\temp\2000001-2000008.m0481pfv50-qual.hdf.tiffBINARY.tiff --outfile=A1_8_SSTQUAL4.tiff --calc="A*B"
gdal_calc.py -A 2000009-2000016.s0481pfv50-sst-16b.hdf.tiff_C.tiff -B C:\temp\2000009-2000016.m0481pfv50-qual.hdf.tiffBINARY.tiff --outfile=A9_16_SSTQUAL4.tiff --calc="A*B"
gdal_calc.py -A 2000017-2000024.s0481pfv50-sst-16b.hdf.tiff_C.tiff -B C:\temp\2000017-2000024.m0481pfv50-qual.hdf.tiffBINARY.tiff --outfile=A17_24_SSTQUAL4.tiff --calc="A*B"
gdal_calc.py -A 2000025-2000032.s0481pfv50-sst-16b.hdf.tiff_C.tiff -B C:\temp\2000025-2000032.m0481pfv50-qual.hdf.tiffBINARY.tiff --outfile=A25_32_SSTQUAL4.tiff --calc="A*B"
gdal_calc.py -A A1_8_SSTQUAL4.tiff -B A9_16_SSTQUAL4.tiff -C A17_24_SSTQUAL4.tiff -D A25_32_SSTQUAL4.tiff --outfile=SST_SUM_C.tiff --calc="A+B+C+D"
gdal_calc.py -A 2000001-2000008.m0481pfv50-qual.hdf.tiffBINARY.tiff -B 2000009-2000016.m0481pfv50-qual.hdf.tiffBINARY.tiff -C 2000017-2000024.m0481pfv50-qual.hdf.tiffBINARY.tiff -D 2000025-2000032.m0481pfv50-qual.hdf.tiffBINARY.tiff --outfile=QUAL_final.tiff --calc="A+B+C+D"
gdal_calc.py -A SST_SUM_C.tiff -B C:\temp\QUAL_final.tiff --outfile=SST_Final_C.tiff --calc="A/B"
gdal_translate SST_Final_C.tiff -of GTiff -ot Float32 -a_nodata 0 SST_Final_C_NoData.tiff
gdal_fillnodata SST_Final_C_NoData.tiff -md 5 -si 2 SST_Final_C_NoData_Foc.tiff
for %%A in ("C:\temp\landmask\*.hdf") do gdal_translate -of GTiff -a_srs "+init=epsg:4326" -a_nodata 2 -a_ullr -180 90 180 -90 -co "COMPRESS=PACKBITS" -sds "%%A" "%%A.tiff"
for %%A in ("C:\temp\landmask\*.tiff") do gdal_calc.py -A "%%A" --outfile="%%A_FINAL.tiff" --calc="1*(A<5)"
gdal_calc.py -A SST_Final_C_NoData_Foc.tiff -B C:\temp\landmask\pfv50_land.m04.hdf.tiff_FINAL.tiff --outfile=SST.tiff --calc="A*B"
gdal_translate SST.tiff -of GTiff -ot UInt16 -a_nodata 0 -stats -co "COMPRESS=LZW" SST_ALLDONE.tiff
pause