Package: majamask
MAJAMASKMajaMask is a small application that lets you create a simplified rastermask from two bitmasks present in Muscate products : CLM and MG2 masks. It can help to visualize key features, though decreases the amount of information initially available.MajaMask can be used as a standalone python module or through StartMaja to compute the rastermask as a direct output.Output mask descriptionMajaMask as a StandaloneMajaMask with StartMaja1 - Output mask descriptionMajaMask generates a rastermask from CLM and MG2 masks of Muscate products. A description of those two masks can be foundhere. Both mask contain information stored in 8-bit images, a combination of which giving the set of detected features for each pixel. In contrast, MajaMask outputs a mask containing only 9 values, each corresponding to one feature. As a result, the output rastermask contains less information but allows quick visual interpretation.The 9 classes of pixels are attributed following a priority order described in the following table :Pixel valueFeatureBit considered in input masks1CirrusCLM bit 72All clouds except cirrusCLM bit 13Cloud shadowsMG2 bit 34SnowMG2 bit 25WaterMG2 bit 06Topological shadowsMG2 bit 47Hidden areas due to terrainMG2 bit 58Tangent or low sunMG2 bit 6 or 70Valid reflectanceNone of the aboveMajaMask as a StandaloneRequirementsMajaMask requires that you work with python >= 3.Additionally, MajaMask will install some dependencies on your environment. In order for majaMask to install dependencies successfully, please :upgrade pip to latest version usingpip install --upgrade pipon your python environment (required by numba)install the following package on your system (required by GDAL) :On Debian/Ubuntu :apt get install libgdal-devOn ReadHat :dnf install gdal-develInstallationIt is advised to install MajaMask in a dedicated python environment.And then, simply use:pip install numpy==1.24.4 && pip install --no-cache-dir gdal==GDAL_VERSION majamaskThe order is important, to get GDAL_VERSION you can executegdalinfo --versionUseUse MajaMask as a command line in a terminal :rastermask -clm <path/to/CLM/tif> -mg2 <path/to/MG2/tif> -out <path/to/output/tif>MajaMask may raise an error if one of these arguments is missing or if CLM and MG2 masks are not 8-bit images of the same size.Alternatively, you can give the path to a L2 product and the application will automatically generate one rastermask for each couple of CLM and MG2 masks found at each resolution :rastermask -product <path/to/L2/product>The generated rastermask(s) will be stored in the<product/Path>/MASKS/folder and will be called rastermask.tif (respectively rastermask_R1.tif for R1 resolution, and so on).Command line arguments (-clm, -mg2, -out) and (-product) are mutually exclusive, please provide one of the two options exactly.You can also use MajaMask as a module in your own python modules, for example:import majamask.rastermask as rastermaskYou can then create a rastermask using thecreate_rastermask(input_mask_clm, input_mask_mg2, output_raster)function. It can be combined with thefind_inputs(product_path)function to automatically find and process all CLM and MG2 masks present in a L2 product :input_array = rastermask.find_inputs(product_folder)
for clm, mg2, out in input_array :
    rastermask.create_rastermask(clm, mg2, out)MajaMask with StartMajaMajaMask module is pre-installed in StartMaja. Details to install MAJA and use StartMaja can be foundhere.MajaMask can be used in StartMaja by setting the option--rastermaskin the StartMaja command line. This will generate the rastermask for all output L2A images. The rastermask will be stored in the same directory as the CLM and MG2 masks (<product/Path>/MASKS/) and calledrastermask.tif. One rastermask will be generated for each resolution (rastermask_R1.tif,rastermask_R2.tif, ...)