# Rescaling¶

Rescaling is a polar2grid component shared by most writers that rescales
gridded image data via the `Rescaler`

object. Rescaling provides simple
enhancement capabilities to prepare the product data for an image format.
The following sections describe each scaling function in the rescaling code.
The defaults provided by Polar2Grid will create nice looking images suitable
for most users.

The functions described below are intended for use by polar2grid writers via
the `Rescaler`

object, but can be used elsewhere if needed.
These functions ignore any fill/invalid values in the data. Common values
for an 8-bit (0-255) output are shown as an example. The `Rescaler`

object uses configuration files
to set how bands are scaled. The function keyword arguments are passed
from the configuration file values.

Note

Rescaling configuration files will change in future versions due to PyTroll collaboration and merging. Please contact us if you have a custom configuration that you need converted to the new (similar) format.

There is a shared clip configuration parameter that defaults to True that will clip data after scaling to the output data limits.

## Linear¶

method: | linear |
---|---|

min_in: | Minimum value for linear parameter calculations |

max_in: | Maximum value for linear parameter calculations |

flip: | Use an inverse linear calculation on the input data |

Note

If `min_in`

and `max_in`

aren't specified they are calculated on the fly from the provided data.

Note

In the default configuration file this method is used as the default rescaling method

Example (10-255 from 173-300):

## Square Root Enhancement¶

method: | sqrt |
---|---|

min_in: | Minimum input value (default: 0.0) |

max_in: | Maximum input value (default: 1.0) |

inner_mult: | Multiplier before calling sqrt (default: 100.0 / max_in) |

outer_mult: | Multiplier after calling sqrt (default: max_out / sqrt(inner_mult * max_in)) |

Example (0-255 from 0-1 data):

## Brightness Temperature¶

method: | btemp |
---|---|

threshold: | Temperature threshold in Kelvin when to do high or low piecewise operations (default: 176/255.0 * max_out) |

min_in: | Minimum input value |

max_in: | Maximum input value |

Example (0-255 from brightness temperature data):

### Fog (Temperature Difference)¶

method: | temperature_difference |
---|---|

min_in: | Minimum input value (default: -10.0) |

max_in: | Maximum input value (default: 10.0) |

## Inverse Linear¶

method: | unlinear |
---|---|

m: | Factor in linear equation |

b: | Offset in linear equation |

Example (0-255 from 0-1 data):

## Lookup¶

method: | lookup |
---|---|

min_in: | Same as Linear scaling |

max_in: | Same as Linear scaling |

table_name: | Name of lookup table to use (default: crefl) |

Note

The `table_name`

argument is optional. The choices are currently hardcoded
in the software. Default is useful for True Color and False Color images.

## Land Surface Temperature¶

method: | lst |
---|

Same as Linear scaling, but 5 is added to `min_out`

and 5 is subtracted from `max_out`

and data is clipped to these
new limits after scaling.

## Cloud Top Temperature¶

method: | ctt |
---|

Same as linear scaling, but 10 is added to `min_out`

and 5 is subtracted from `max_out`

and data is clipped to these
new limits after scaling.

## NDVI¶

method: | ndvi |
---|---|

min_in: | Minimum input value (default: -1.0) |

max_in: | Maximum input value (default: 1.0) |

threshold: | Threshold between 'low' and 'high' operations (default: 0.0) |

threshold_out: | Output maximum for 'low' operations and minimum for 'high' operations (default: 49 / 255.0 * max_out) |