Commit 1600b2bd authored by Antonio Valentino's avatar Antonio Valentino

Import Upstream version 0.1.0

parents
[bumpversion]
current_version = 0.1.0
commit = True
tag = True
[bumpversion:file:pyninjotiff/version.py]
##
## Format
##
## ACTION: [AUDIENCE:] COMMIT_MSG [!TAG ...]
##
## Description
##
## ACTION is one of 'chg', 'fix', 'new'
##
## Is WHAT the change is about.
##
## 'chg' is for refactor, small improvement, cosmetic changes...
## 'fix' is for bug fixes
## 'new' is for new features, big improvement
##
## AUDIENCE is optional and one of 'dev', 'usr', 'pkg', 'test', 'doc'
##
## Is WHO is concerned by the change.
##
## 'dev' is for developpers (API changes, refactors...)
## 'usr' is for final users (UI changes)
## 'pkg' is for packagers (packaging changes)
## 'test' is for testers (test only related changes)
## 'doc' is for doc guys (doc only changes)
##
## COMMIT_MSG is ... well ... the commit message itself.
##
## TAGs are additionnal adjective as 'refactor' 'minor' 'cosmetic'
##
## They are preceded with a '!' or a '@' (prefer the former, as the
## latter is wrongly interpreted in github.) Commonly used tags are:
##
## 'refactor' is obviously for refactoring code only
## 'minor' is for a very meaningless change (a typo, adding a comment)
## 'cosmetic' is for cosmetic driven change (re-indentation, 80-col...)
## 'wip' is for partial functionality but complete subfunctionality.
##
## Example:
##
## new: usr: support of bazaar implemented
## chg: re-indentend some lines !cosmetic
## new: dev: updated code to be compatible with last version of killer lib.
## fix: pkg: updated year of licence coverage.
## new: test: added a bunch of test around user usability of feature X.
## fix: typo in spelling my name in comment. !minor
##
## Please note that multi-line commit message are supported, and only the
## first line will be considered as the "summary" of the commit message. So
## tags, and other rules only applies to the summary. The body of the commit
## message will be displayed in the changelog without reformatting.
##
## ``ignore_regexps`` is a line of regexps
##
## Any commit having its full commit message matching any regexp listed here
## will be ignored and won't be reported in the changelog.
##
ignore_regexps = [
r'@minor', r'!minor',
r'@cosmetic', r'!cosmetic',
r'@refactor', r'!refactor',
r'@wip', r'!wip',
r'^Merge commit .* into HEAD',
r'^([cC]hg|[fF]ix|[nN]ew)\s*:\s*[p|P]kg:',
r'^([cC]hg|[fF]ix|[nN]ew)\s*:\s*[d|D]ev:',
r'^(.{3,3}\s*:)?\s*[fF]irst commit.?\s*$',
]
## ``section_regexps`` is a list of 2-tuples associating a string label and a
## list of regexp
##
## Commit messages will be classified in sections thanks to this. Section
## titles are the label, and a commit is classified under this section if any
## of the regexps associated is matching.
##
section_regexps = [
('New', [
r'^[nN]ew\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
]),
('Changes', [
r'^[cC]hg\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
]),
('Fix', [
r'^([Bb]ug)?[fF]ix\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
]),
('Other', None ## Match all lines
),
]
## ``body_process`` is a callable
##
## This callable will be given the original body and result will
## be used in the changelog.
##
## Available constructs are:
##
## - any python callable that take one txt argument and return txt argument.
##
## - ReSub(pattern, replacement): will apply regexp substitution.
##
## - Indent(chars=" "): will indent the text with the prefix
## Please remember that template engines gets also to modify the text and
## will usually indent themselves the text if needed.
##git log --pretty=format:"- %s%n%b" --since="$(git show -s --format=%ad `git rev-list --tags --max-count=1`)"
## - Wrap(regexp=r"\n\n"): re-wrap text in separate paragraph to fill 80-Columns
##
## - noop: do nothing
##
## - ucfirst: ensure the first letter is uppercase.
## (usually used in the ``subject_process`` pipeline)
##
## - final_dot: ensure text finishes with a dot
## (usually used in the ``subject_process`` pipeline)
##
## - strip: remove any spaces before or after the content of the string
##
## Additionally, you can `pipe` the provided filters, for instance:
#body_process = Wrap(regexp=r'\n(?=\w+\s*:)') | Indent(chars=" ")
#body_process = Wrap(regexp=r'\n(?=\w+\s*:)')
#body_process = noop
body_process = ReSub(r'(?m)\s*^Signed-off-by: .*$\s*', '')
## ``subject_process`` is a callable
##
## This callable will be given the original subject and result will
## be used in the changelog.
##
## Available constructs are those listed in ``body_process`` doc.
subject_process = (strip |
ReSub(r'^([cC]hg|[fF]ix|[nN]ew)\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n@]*)(@[a-z]+\s+)*$', r'\4') |
#ucfirst | final_dot)
final_dot)
#subject_process = noop
## ``tag_filter_regexp`` is a regexp
##
## Tags that will be used for the changelog must match this regexp.
##
tag_filter_regexp = r'^v[0-9]+\.[0-9]+(\.[0-9]+)?$'
## ``unreleased_version_label`` is a string
##
## This label will be used as the changelog Title of the last set of changes
## between last valid tag and HEAD if any.
unreleased_version_label = "%%version%% (unreleased)"
## ``output_engine`` is a callable
##
## This will change the output format of the generated changelog file
##
## Available choices are:
##
## - rest_py
##
## Legacy pure python engine, outputs ReSTructured text.
## This is the default.
##
## - mustache(<template_name>)
##
## Template name could be any of the available templates in
## ``templates/mustache/*.tpl``.
## Requires python package ``pystache``.
## Examples:
## - mustache("markdown")
## - mustache("restructuredtext")
##
## - makotemplate(<template_name>)
##
## Template name could be any of the available templates in
## ``templates/mako/*.tpl``.
## Requires python package ``mako``.
## Examples:
## - makotemplate("restructuredtext")
##
output_engine = rest_py
#output_engine = mustache("restructuredtext")
#output_engine = mustache("markdown")
#output_engine = makotemplate("restructuredtext")
## ``include_merges`` is a boolean
##
## This option tells git-log whether to include merge commits in the log.
## The default is to include them.
include_merges = False
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# IPython Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# dotenv
.env
# virtualenv
venv/
ENV/
# Spyder project settings
.spyderproject
# Rope project settings
.ropeproject
This diff is collapsed.
# pyninjotiff
python library for writing Ninjo-compatible TIFF files
Changelog
=========
v0.1.0 (2017-10-16)
-------------------
- update changelog. [Martin Raspaud]
- Bump version: 0.0.1 → 0.1.0. [Martin Raspaud]
- Add housekeeping files. [Martin Raspaud]
- Merge pull request #2 from goodsonr/fix-user-corner-of-pixel-coords.
[Martin Raspaud]
Fix - use corner of pixel coords
- Style fixes. [goodsonr]
- Add files via upload. [goodsonr]
- Navigation Fix. [goodsonr]
Use corners of pixels for navigation instead of center of pixel
Change to use utility routines to get projection semi-major / semi-minor axis
- Merge pull request #1 from loreclem/master. [Martin Raspaud]
NinjoTiff minimal example with satpy
- NinjoTiff minimal example with satpy. [lorenzo clementi]
- Bugfix. [Martin Raspaud]
- First commit, copy files from mpop. [Martin Raspaud]
- Initial commit. [Martin Raspaud]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2017 Martin Raspaud
# Author(s):
# Martin Raspaud <martin.raspaud@smhi.se>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Init file."""
This diff is collapsed.
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
ninjotiff_example
Created on Wed Dec 2 10:00:18 2015
@author: ras
This example is using a ninjotiff.cfg file. If you prefer to pass all
meta-data by arguments, they can be defined like:
ninjotiff_config = {
0.6: {'description': 'MSG Channel 1',
'sat_id': 6200014,
'chan_id': 100015,
'data_cat': 'GORN',
'data_source': 'EUMETCAST'},
10.8: {'description': 'MSG Channel 9',
'sat_id': 6200014,
'chan_id': 900015,
'data_cat': 'GORN',
'data_source': 'EUMETCAST'},
'HRV': {'description': 'MSG Channel 12',
'sat_id': 6200014,
'chan_id': 1200015,
'data_cat': 'GORN',
'data_source': 'EUMETCAST'},
}
Saving an image for 'chn' will then go like:
image.save(filename,
fformat='mpop.imageo.formats.ninjotiff',
physic_unit=physic_unit,
ch_min_measurement_unit=min_value,
ch_max_measurement_unit=max_value,
**ninjotiff_config[chn])
"""
import sys
import os
from datetime import datetime, timedelta
import logging
logging.basicConfig(level=logging.DEBUG)
# Basic check.
try:
os.environ['PPP_CONFIG_DIR']
except KeyError:
print >>sys.stderr, "PPP_CONFIG_DIR is not defined"
sys.exit(2)
from mpop.satellites import GeostationaryFactory
import mpop.utils
LOG = mpop.utils.get_logger(__name__)
if "DEBUG" in os.environ:
mpop.utils.debug_on()
# Handle argument.
try:
filename = sys.argv[1]
except IndexError:
print >> sys.stderr, "usage: ninjotiff_example <MSG EPI filename>"
exit(2)
i__ = os.path.basename(filename).split('-')
TIMESLOT = datetime.strptime(i__[6], '%Y%m%d%H%M')
SATNO = "%02d" % (7 + int(i__[2][3]))
# Areas to be loaded into and to be projected onto.
AREAS = (
('visir_full', 'MSGF', 'msg_pc'),
#('hrv_north', 'MSGHRVN', 'msg_hrvn_pc')
)
CHANNEL_DICT = {
#'visir_full': (0.6, 0.8, 1.6, 3.9, 6.2, 7.3, 8.7, 9.7, 10.8, 12.0, 13.4),
'visir_full': (0.6, 10.8,),
'hrv_north': ('HRV',)
}
BITS_PER_SAMPLE = 8
DO_CONVECTION = False
for area_name, area_in, area_out in AREAS:
global_data = GeostationaryFactory.create_scene("meteosat",
SATNO,
"seviri",
area=area_in,
time_slot=TIMESLOT)
# Load channel by channel (to save memory).
for chn in CHANNEL_DICT[area_name]:
global_data.load([chn])
chn_name = global_data[chn].name
# Save 'unit' ... it seems to be lost somewhere.
global_data[chn].unit = global_data[chn].info.get('units', 'None')
# Resample to Plate Caree.
scene = global_data.project(area_out, mode='quick', precompute=True)
# Kelvin -> Celsius.
physic_unit = scene[chn].unit.upper()
if physic_unit in ('K', 'KELVIN'):
scene[chn].data -= 273.15
physic_unit = scene[chn].unit = 'C'
# Value range as DWD
if physic_unit in ('C', 'CELSIUS'):
# IR
value_range = (-88.5, 40.)
else:
# VIS
value_range = (0., 125.)
#
# A GeoImage specifying a color range.
#
# If no color_range specified, MPOP will not scaled the data into the [0., 1.] range.
# In that case set the data_is_scaled_01 option to False in img.save
#
img = scene.image(chn, mode="L", crange=[value_range])
LOG.info("%s (%s, %s) %.2f %.2f %.2f" % (chn_name, physic_unit,
img.channels[0].dtype,
img.channels[0].min(),
img.channels[0].mean(),
img.channels[0].max()))
#
# Save it to Ninjo tif format, pass physics unit and Ninjo product name
# (by "coincidence" product name correspond to MPOP's channel name :).
#
# If physics unit is not passed, we will expect to find it in ninjotiff's config file.
#
filename = ('MSG-' + TIMESLOT.strftime("%Y%m%d_%H%M") + '-' +
area_name.split('_')[-1] + '-' + chn_name + '-%db.tif' % BITS_PER_SAMPLE)
LOG.info("Saving to Ninjo tif %s" % filename)
img.save(filename,
fformat='mpop.imageo.formats.ninjotiff',
physic_unit=physic_unit,
ninjo_product_name=chn_name,
ch_min_measurement_unit=value_range[0],
ch_max_measurement_unit=value_range[1],
nbits=BITS_PER_SAMPLE)
# Cleanup.
scene.unload([chn])
global_data.unload([chn])
if DO_CONVECTION:
#
# RGB example, convection
#
# NOT ready for 16 bit
BITS_PER_SAMPLE = 8
product_name = 'convection'
area_name, area_in, area_out = ('visir_europe', 'MSGNH', 'msg_ninjo_europe_big')
channels = [0.635, 1.63, 3.75, 6.7, 7.3, 10.8]
global_data = GeostationaryFactory.create_scene("meteosat",
SATNO,
"seviri",
area=area_in,
time_slot=TIMESLOT)
# Load channels.
global_data.load(channels)
# Resample to Plate Caree.
scene = global_data.project(area_out, mode='quick', precompute=True)
img = scene.image.convection()
filename = ('MSG-' + TIMESLOT.strftime("%Y%m%d_%H%M") + '-' +
area_name.split('_')[-1] + '-' + product_name + '-%db.tif' % BITS_PER_SAMPLE)
LOG.info("Saving to Ninjo tif %s" % filename)
img.save(filename,
fformat='mpop.imageo.formats.ninjotiff',
ninjo_product_name='msg_' + product_name,
nbits=BITS_PER_SAMPLE)
import os
from satpy import Scene
from datetime import datetime
from satpy.utils import debug_on
import pyninjotiff
debug_on()
chn=10.8
time_slot = datetime(2017, 1, 27, 7, 45)
global_data = Scene(platform_name="Meteosat-10", sensor="seviri", reader="hrit_msg", start_time=time_slot)
global_data.load([chn])
local_scene = global_data.resample("NinJoRegion")
local_scene.save_dataset(chn, filename="msg.tif", writer='ninjotiff',
sat_id=1234,
chan_id=5678,
data_cat='GORN',
data_source='EUMETSAT/MeteoSwiss',
physic_unit='K',
nbits=8)
This diff is collapsed.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2017 Martin Raspaud
# Author(s):
# Martin Raspaud <martin.raspaud@smhi.se>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Version file."""
__version__ = "v0.1.0"
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2017 Martin Raspaud
# Author(s):
# Martin Raspaud <martin.raspaud@smhi.se>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Setup for pyninjotiff.
"""
import imp
from setuptools import setup
version = imp.load_source('pyninjotiff.version', 'pyninjotiff/version.py')
setup(name="pyninjotiff",
version=version.__version__,
description='Pytroll imaging library',
author='Martin Raspaud',
author_email='martin.raspaud@smhi.se',
classifiers=["Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU General Public License v3 " +
"or later (GPLv3+)",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Topic :: Scientific/Engineering"],
url="https://github.com/pytroll/pyninjotiff",
packages=['pyninjotiff'],
zip_safe=False,
install_requires=['numpy >=1.6', 'six'],
# test_suite='pyninjotiff.tests.suite',
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment