Skip to content

Commit be0a39d

Browse files
authored
use entrypoints instead of .py scripts for the command line (#75)
1 parent 866ee42 commit be0a39d

14 files changed

+43
-10
lines changed

INSTALL.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2+
WARNING: To install python-fmask it is strongly recommended to use the conda forge
3+
pre-built binaries. Only install from source if you absolutely must.
4+
5+
16
To install python-fmask from the source code bundle, use the following commands
27

38
First unpack the bundle. For the tar.gz file, this would be

bin/fmask_sentinel2Stacked.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1818

1919
from fmask.cmdline import sentinel2Stacked
20+
import warnings
21+
warnings.warn("Future versions of fmask may remove the .py extension from this script name", DeprecationWarning)
2022

2123
if __name__ == '__main__':
2224
sentinel2Stacked.mainRoutine()

bin/fmask_sentinel2makeAnglesImage.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1818

1919
from fmask.cmdline import sentinel2makeAnglesImage
20+
import warnings
21+
warnings.warn("Future versions of fmask may remove the .py extension from this script name", DeprecationWarning)
2022

2123
if __name__ == "__main__":
2224
sentinel2makeAnglesImage.mainRoutine()

bin/fmask_usgsLandsatMakeAnglesImage.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1818

1919
from fmask.cmdline import usgsLandsatMakeAnglesImage
20+
import warnings
21+
warnings.warn("Future versions of fmask may remove the .py extension from this script name", DeprecationWarning)
2022

2123
if __name__ == "__main__":
2224
usgsLandsatMakeAnglesImage.mainRoutine()

bin/fmask_usgsLandsatSaturationMask.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1818

1919
from fmask.cmdline import usgsLandsatSaturationMask
20+
import warnings
21+
warnings.warn("Future versions of fmask may remove the .py extension from this script name", DeprecationWarning)
2022

2123
if __name__ == '__main__':
2224
usgsLandsatSaturationMask.mainRoutine()

bin/fmask_usgsLandsatStacked.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1818

1919
from fmask.cmdline import usgsLandsatStacked
20-
20+
import warnings
21+
warnings.warn("Future versions of fmask may remove the .py extension from this script name", DeprecationWarning)
22+
2123
if __name__ == '__main__':
2224
usgsLandsatStacked.mainRoutine()
2325

bin/fmask_usgsLandsatTOA.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1818

1919
from fmask.cmdline import usgsLandsatTOA
20+
import warnings
21+
warnings.warn("Future versions of fmask may remove the .py extension from this script name", DeprecationWarning)
2022

2123
if __name__ == '__main__':
2224
usgsLandsatTOA.mainRoutine()

doc/source/index.rst

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ The command line scripts supplied can process an untarred USGS Landsat scene.
102102
Here is an example of how to do this. This command will take a given scene directory,
103103
find the right images, and create an output file called cloud.img::
104104

105-
fmask_usgsLandsatStacked.py -o cloud.img --scenedir LC08_L1TP_150033_20150413_20170410_01_T1
105+
fmask_usgsLandsatStacked -o cloud.img --scenedir LC08_L1TP_150033_20150413_20170410_01_T1
106106

107107
If the thermal band is empty (for Landsat-8 with the SSM anomaly, after 2015-11-01) then it
108108
is ignored gracefully.
@@ -125,13 +125,13 @@ slower, and is unlikely to be any more accurate.
125125
This command will take a given .SAFE directory, find the right images, and create an
126126
output file called cloud.img::
127127

128-
fmask_sentinel2Stacked.py -o cloud.img --safedir S2B_MSIL1C_20180918T235239_N0206_R130_T56JNQ_20180919T011001.SAFE
128+
fmask_sentinel2Stacked -o cloud.img --safedir S2B_MSIL1C_20180918T235239_N0206_R130_T56JNQ_20180919T011001.SAFE
129129

130130
When working with the old ESA zipfile format, which packed multiple tiles into a single SAFE-format
131131
zipfile, this approach will not work, as it won't know which tile to process. So, instead, use
132132
the option to specify the granule directory, as follows::
133133

134-
fmask_sentinel2Stacked.py -o cloud.img --granuledir S2A_OPER_PRD_MSIL1C_PDMC_20160111T072442_R030_V20160111T000425_20160111T000425.SAFE/GRANULE/S2A_OPER_MSI_L1C_TL_SGS__20160111T051031_A002887_T56JNQ_N02.01
134+
fmask_sentinel2Stacked -o cloud.img --granuledir S2A_OPER_PRD_MSIL1C_PDMC_20160111T072442_R030_V20160111T000425_20160111T000425.SAFE/GRANULE/S2A_OPER_MSI_L1C_TL_SGS__20160111T051031_A002887_T56JNQ_N02.01
135135

136136
This would also work on a new-format directory, but specifying the top .SAFE directory is easier.
137137

@@ -155,13 +155,11 @@ Get the source as a bundle from `GitHub <https://github.com/ubarsc/python-fmask/
155155
Release notes for each version can be read in :doc:`releasenotes`. To install from source,
156156
read the INSTALL.txt file included inside the source bundle.
157157

158-
Pre-built binary `Conda <http://conda.pydata.org/miniconda.html#miniconda>`_ packages are available
158+
Pre-built binary `Conda <https://github.com/conda-forge/miniforge>`_ packages are available
159159
under the 'conda-forge' channel. Once you have installed
160-
`Conda <http://conda.pydata.org/miniconda.html#miniconda>`_, run the following commands on the
160+
`Conda <https://github.com/conda-forge/miniforge>`_, run the following commands on the
161161
command line to install python-fmask: ::
162162

163-
conda config --add channels conda-forge
164-
conda config --set channel_priority strict
165163
conda create -n myenv python-fmask
166164
conda activate myenv
167165

fmask/config.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
from rios import applier
2929
from . import fmaskerrors
3030

31+
gdal.UseExceptions()
32+
3133
FMASK_LANDSAT47 = 0
3234
"Landsat 4 to 7"
3335
FMASK_LANDSAT8 = 1
@@ -436,7 +438,7 @@ def setTOAReflectanceFile(self, toaRefFile):
436438
This should have numbers which are reflectance * 1000
437439
438440
Use the :func:`fmask.landsatTOA.makeTOAReflectance` function to create
439-
this file from raw Landsat radiance (or the fmask_usgsLandsatTOA.py
441+
this file from raw Landsat radiance (or the fmask_usgsLandsatTOA
440442
command line program supplied with fmask).
441443
442444
It is assumed that any values that are nulls in the original radiance
@@ -686,7 +688,7 @@ def __init__(self, solarZenithFilename, solarZenithBand, solarAzimuthFilename,
686688
self.viewZenithData = None
687689
self.viewAzimuthData = None
688690

689-
# This default value matches the file produced by fmask_usgsLandsatMakeAnglesImage.py
691+
# This default value matches the file produced by fmask_usgsLandsatMakeAnglesImage
690692
self.scaleToRadians = 0.01
691693

692694
@staticmethod

fmask/fmask.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
from . import zerocheck
7272

7373
numpy.seterr(all='raise')
74+
gdal.UseExceptions()
7475

7576
# Bands in the saturation mask, if supplied
7677
SATURATION_BLUE = 0

fmask/landsatTOA.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
from rios import applier, cuiprogress, fileinfo
2727
from . import config
2828

29+
gdal.UseExceptions()
30+
2931
# Derived by Pete Bunting from 6S
3032
LANDSAT8_ESUN = [1876.61, 1970.03, 1848.9, 1571.3, 967.66, 245.73, 82.03, 361.72]
3133
# From Chander, G., Markham, B.L., Helder, D.L. (2008)

fmask/landsatangles.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@
6868
from rios import applier
6969
from rios import fileinfo
7070

71+
osr.UseExceptions()
72+
7173

7274
def findImgCorners(img, imgInfo):
7375
"""

fmask/sen2meta.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
from . import fmaskerrors
3333

34+
osr.UseExceptions()
35+
3436

3537
class Sen2TileMeta(object):
3638
"""

setup.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@
6262
author='Neil Flood',
6363
author_email='n.flood@uq.edu.au',
6464
scripts=scriptList,
65+
entry_points={
66+
'console_scripts': [
67+
'fmask_sentinel2makeAnglesImage = fmask.cmdline.sentinel2makeAnglesImage:mainRoutine',
68+
'fmask_sentinel2Stacked = fmask.cmdline.sentinel2Stacked:mainRoutine',
69+
'fmask_usgsLandsatMakeAnglesImage = fmask.cmdline.usgsLandsatMakeAnglesImage:mainRoutine',
70+
'fmask_usgsLandsatSaturationMask = fmask.cmdline.usgsLandsatSaturationMask:mainRoutine',
71+
'fmask_usgsLandsatStacked = fmask.cmdline.usgsLandsatStacked:mainRoutine',
72+
'fmask_usgsLandsatTOA = fmask.cmdline.usgsLandsatTOA:mainRoutine'
73+
]},
6574
packages=['fmask', 'fmask/cmdline'],
6675
ext_package='fmask',
6776
ext_modules=extensionsList,

0 commit comments

Comments
 (0)