This is an automated email from the git hooks/post-receive script. a_valentino-guest pushed a commit to branch master in repository mipp.
commit a3720ad5797b00d5dc8a8dc15a4b2b283211c4a4 Author: Antonio Valentino <[email protected]> Date: Mon Oct 31 16:39:49 2016 +0000 New upstream version 1.0.0 --- .bumpversion.cfg | 7 ++ .gitchangelog.rc | 192 ++++++++++++++++++++++++++++++++++ changelog.rst | 51 +++++++++ mipp/version.py | 2 +- mipp/xrit/MSG.py | 151 +++++++++++++++++--------- mipp/xrit/sat.py | 54 ++++++---- mipp/xsar/S1A.py | 3 +- setup.py | 18 ++-- tests/data/MSG2_HRV_20101011_1400.mda | 2 +- tests/data/MSG2_HRV_20101109_1200.mda | 2 +- 10 files changed, 397 insertions(+), 85 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg new file mode 100644 index 0000000..e582466 --- /dev/null +++ b/.bumpversion.cfg @@ -0,0 +1,7 @@ +[bumpversion] +current_version = 1.0.0 +commit = True +tag = True + +[bumpversion:file:mipp/version.py] + diff --git a/.gitchangelog.rc b/.gitchangelog.rc new file mode 100644 index 0000000..80c1ea7 --- /dev/null +++ b/.gitchangelog.rc @@ -0,0 +1,192 @@ +## +## 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) + + +## ``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 diff --git a/changelog.rst b/changelog.rst index 31014fd..0367e60 100644 --- a/changelog.rst +++ b/changelog.rst @@ -1,6 +1,57 @@ Changelog ========= +v1.0.0 (2016-10-27) +------------------- + +- Update changelog. [Martin Raspaud] + +- Bump version: 0.10.0 → 1.0.0. [Martin Raspaud] + +- Merge branch 'master' into release-1.0.0. [Martin Raspaud] + + Conflicts: + mipp/xrit/MSG.py + + +- Merge branch 'pre-master' [Martin Raspaud] + + Conflicts: + mipp/xrit/MSG.py + +- Merge pull request #5 from sebiegli/master. [Martin Raspaud] + + fixed Issue #4 + +- Fixed Issue #4. [Sebastian] + +- Add bump and changelog config files. [Martin Raspaud] + +- Fix pep8 compliance. [Martin Raspaud] + +- Accept unicode filenames. [Martin Raspaud] + +- Fix the lowering of case in load_files for the platform name. [Martin + Raspaud] + +- Allow platform name to be provided to load_files. [Martin Raspaud] + + This is usefull for H8 files for exemple, since they don't have + prologues. + +- Fixed Issue #4. [Sebastian] + +- Corrected tests, after last checkin. [Lars Orum Rasmussen] + +- Sentinel reader independent of S1A and S1B. [Lars Orum Rasmussen] + +- Define download_url. [Lars Orum Rasmussen] + + Better url (usr pytroll organization) + + pep8 + + v0.10.0 (2016-05-16) -------------------- diff --git a/mipp/version.py b/mipp/version.py index 50a6d40..27533cc 100644 --- a/mipp/version.py +++ b/mipp/version.py @@ -25,4 +25,4 @@ """Version file. """ -__version__ = "v0.10.0" +__version__ = "v1.0.0" diff --git a/mipp/xrit/MSG.py b/mipp/xrit/MSG.py index 90d9bec..2b153a7 100644 --- a/mipp/xrit/MSG.py +++ b/mipp/xrit/MSG.py @@ -22,21 +22,23 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -"""This module will read MSG level1.5 files, format documented in: +"""This module will read MSG level1.5 files, format documented in: 'MSG Level 1.5 Image Data Format Description', EUM/MSG/ICD/105, v5A, 22 August 2007 """ #raise NotImplementedError import logging -logger = logging.getLogger(__name__) - import sys -import numpy as np from StringIO import StringIO +import numpy as np + from mipp import CalibrationError -from mipp.xrit import _xrit -from mipp.xrit import Metadata from mipp.xrit import bin_reader as rbin +from mipp.xrit import Metadata, _xrit + +logger = logging.getLogger(__name__) + + __all__ = ['read_metadata'] @@ -273,7 +275,8 @@ class _Calibrator(object): mask = (image == no_data_value) if self.bits_per_pixel == 8: - logger.info("8 bits per pixel adjusted to 10 bits for calibration.") + logger.info( + "8 bits per pixel adjusted to 10 bits for calibration.") image = image.astype(np.uint16) * 4 cslope = hdr["Level1_5ImageCalibration"][chn_nb]['Cal_Slope'] @@ -311,7 +314,7 @@ class _Calibrator(object): # computation based on spectral radiance cal_data = eval_np(('C2 * 100. * wavenumber / ' 'log(C1 * 1.0e6 * wavenumber ** 3 / ' - '(1.0e-5 * radiances) + 1))')) + '(1.0e-5 * radiances) + 1)')) coef_a = eval("BTFIT_A_" + channel_name) coef_b = eval("BTFIT_B_" + channel_name) @@ -428,28 +431,40 @@ def read_proheader(fp): # RadiometerSettings radiosettings = {} - radiosettings["MDUSamplingDelays"] = np.fromstring(fp.read(42 * 2), dtype=">u2") + radiosettings["MDUSamplingDelays"] = np.fromstring( + fp.read(42 * 2), dtype=">u2") radiosettings["HRVFrameOffsets"] = {} - radiosettings["HRVFrameOffsets"]["MDUNomHRVDelay1"] = rbin.read_uint2(fp.read(2)) - radiosettings["HRVFrameOffsets"]["MDUNomHRVDelay2"] = rbin.read_uint2(fp.read(2)) + radiosettings["HRVFrameOffsets"][ + "MDUNomHRVDelay1"] = rbin.read_uint2(fp.read(2)) + radiosettings["HRVFrameOffsets"][ + "MDUNomHRVDelay2"] = rbin.read_uint2(fp.read(2)) radiosettings["HRVFrameOffsets"]["Spare"] = rbin.read_uint2(fp.read(2)) - radiosettings["HRVFrameOffsets"]["MDUNomHRVBreakline"] = rbin.read_uint2(fp.read(2)) + radiosettings["HRVFrameOffsets"][ + "MDUNomHRVBreakline"] = rbin.read_uint2(fp.read(2)) radiosettings["DHSSSynchSelection"] = ord(fp.read(1)) radiosettings["MDUOutGain"] = np.fromstring(fp.read(42 * 2), dtype=">u2") radiosettings["MDUCourseGain"] = np.fromstring(fp.read(42), dtype=np.uint8) radiosettings["MDUFineGain"] = np.fromstring(fp.read(42 * 2), dtype=">u2") - radiosettings["MDUNumericalOffset"] = np.fromstring(fp.read(42 * 2), dtype=">u2") + radiosettings["MDUNumericalOffset"] = np.fromstring( + fp.read(42 * 2), dtype=">u2") radiosettings["PUGain"] = np.fromstring(fp.read(42 * 2), dtype=">u2") radiosettings["PUOffset"] = np.fromstring(fp.read(27 * 2), dtype=">u2") radiosettings["PUBias"] = np.fromstring(fp.read(15 * 2), dtype=">u2") radiosettings["OperationParameters"] = {} - radiosettings["OperationParameters"]["L0_LineCounter"] = rbin.read_uint2(fp.read(2)) - radiosettings["OperationParameters"]["K1_RetraceLines"] = rbin.read_uint2(fp.read(2)) - radiosettings["OperationParameters"]["K2_PauseDeciseconds"] = rbin.read_uint2(fp.read(2)) - radiosettings["OperationParameters"]["K3_RetraceLines"] = rbin.read_uint2(fp.read(2)) - radiosettings["OperationParameters"]["K4_PauseDeciseconds"] = rbin.read_uint2(fp.read(2)) - radiosettings["OperationParameters"]["K5_RetraceLines"] = rbin.read_uint2(fp.read(2)) - radiosettings["OperationParameters"]["X_DeepSpaceWindowPosition"] = ord(fp.read(1)) + radiosettings["OperationParameters"][ + "L0_LineCounter"] = rbin.read_uint2(fp.read(2)) + radiosettings["OperationParameters"][ + "K1_RetraceLines"] = rbin.read_uint2(fp.read(2)) + radiosettings["OperationParameters"][ + "K2_PauseDeciseconds"] = rbin.read_uint2(fp.read(2)) + radiosettings["OperationParameters"][ + "K3_RetraceLines"] = rbin.read_uint2(fp.read(2)) + radiosettings["OperationParameters"][ + "K4_PauseDeciseconds"] = rbin.read_uint2(fp.read(2)) + radiosettings["OperationParameters"][ + "K5_RetraceLines"] = rbin.read_uint2(fp.read(2)) + radiosettings["OperationParameters"][ + "X_DeepSpaceWindowPosition"] = ord(fp.read(1)) radiosettings["RefocusingLines"] = rbin.read_uint2(fp.read(2)) radiosettings["RefocusingDirection"] = ord(fp.read(1)) radiosettings["RefocusingPosition"] = rbin.read_uint2(fp.read(2)) @@ -470,8 +485,10 @@ def read_proheader(fp): radiooper["LastGainChangeTime"] = rbin.read_cds_time(fp.read(6)) radiooper["Decontamination"] = {} radiooper["Decontamination"]["DecontaminationNow"] = ord(fp.read(1)) > 0 - radiooper["Decontamination"]["DecontaminationStart"] = rbin.read_cds_time(fp.read(6)) - radiooper["Decontamination"]["DecontaminationEnd"] = rbin.read_cds_time(fp.read(6)) + radiooper["Decontamination"][ + "DecontaminationStart"] = rbin.read_cds_time(fp.read(6)) + radiooper["Decontamination"][ + "DecontaminationEnd"] = rbin.read_cds_time(fp.read(6)) radiooper["BBCalScheduled"] = ord(fp.read(1)) > 0 radiooper["BBCalibrationType"] = ord(fp.read(1)) @@ -600,13 +617,17 @@ def read_proheader(fp): # RPSummary rpsummary = {} - rpsummary["RadianceLinearization"] = np.fromstring(fp.read(12), dtype=np.bool) + rpsummary["RadianceLinearization"] = np.fromstring( + fp.read(12), dtype=np.bool) - rpsummary["DetectorEqualization"] = np.fromstring(fp.read(12), dtype=np.bool) - rpsummary["OnboardCalibrationResult"] = np.fromstring(fp.read(12), dtype=np.bool) + rpsummary["DetectorEqualization"] = np.fromstring( + fp.read(12), dtype=np.bool) + rpsummary["OnboardCalibrationResult"] = np.fromstring( + fp.read(12), dtype=np.bool) rpsummary["MPEFCalFeedback"] = np.fromstring(fp.read(12), dtype=np.bool) rpsummary["MTFAdaptation"] = np.fromstring(fp.read(12), dtype=np.bool) - rpsummary["StraylightCorrectionFlag"] = np.fromstring(fp.read(12), dtype=np.bool) + rpsummary["StraylightCorrectionFlag"] = np.fromstring( + fp.read(12), dtype=np.bool) hdr["RPSummary"] = rpsummary @@ -614,7 +635,8 @@ def read_proheader(fp): caltype = np.dtype([('Cal_Slope', '>f8'), ('Cal_Offset', '>f8')]) - hdr["Level1_5ImageCalibration"] = np.fromstring(fp.read(192), dtype=caltype) + hdr["Level1_5ImageCalibration"] = np.fromstring( + fp.read(192), dtype=caltype) # BlackBodyDataUsed @@ -622,7 +644,8 @@ def read_proheader(fp): bbdu["BBObservationUTC"] = rbin.read_cds_expanded_time(fp.read(10)) bbdu["BBRelatedData"] = {} - bbdu["BBRelatedData"]["OnBoardBBTime"] = rbin.read_cuc_time(fp.read(7), 4, 3) + bbdu["BBRelatedData"][ + "OnBoardBBTime"] = rbin.read_cuc_time(fp.read(7), 4, 3) bbdu["BBRelatedData"]["MDUOutGain"] = np.fromstring(fp.read(42 * 2), dtype=">u2") bbdu["BBRelatedData"]["MDUCoarseGain"] = np.fromstring(fp.read(42), @@ -647,34 +670,56 @@ def read_proheader(fp): bbdu["BBRelatedData"]["DCRValues"] = result bbdu["BBRelatedData"]["X_DeepSpaceWindowPosition"] = ord(fp.read(1)) bbdu["BBRelatedData"]["ColdFPTemperature"] = {} - bbdu["BBRelatedData"]["ColdFPTemperature"]["FCUNominalColdFocalPlaneTemp"] = rbin.read_uint2(fp.read(2)) / 100. - bbdu["BBRelatedData"]["ColdFPTemperature"]["FCURedundantColdFocalPlaneTemp"] = rbin.read_uint2(fp.read(2)) / 100. + bbdu["BBRelatedData"]["ColdFPTemperature"][ + "FCUNominalColdFocalPlaneTemp"] = rbin.read_uint2(fp.read(2)) / 100. + bbdu["BBRelatedData"]["ColdFPTemperature"][ + "FCURedundantColdFocalPlaneTemp"] = rbin.read_uint2(fp.read(2)) / 100. bbdu["BBRelatedData"]["WarmFPTemperature"] = {} - bbdu["BBRelatedData"]["WarmFPTemperature"]["FCUNominalWarmFocalPlaneVHROTemp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 - bbdu["BBRelatedData"]["WarmFPTemperature"]["FCURedundantWarmFocalPlaneVHROTemp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 + bbdu["BBRelatedData"]["WarmFPTemperature"][ + "FCUNominalWarmFocalPlaneVHROTemp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 + bbdu["BBRelatedData"]["WarmFPTemperature"][ + "FCURedundantWarmFocalPlaneVHROTemp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 bbdu["BBRelatedData"]["ScanMirrorTemperature"] = {} - bbdu["BBRelatedData"]["ScanMirrorTemperature"]["FCUNominalScanMirrorSensor1Temp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 - bbdu["BBRelatedData"]["ScanMirrorTemperature"]["FCURedundantScanMirrorSensor1Temp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 - bbdu["BBRelatedData"]["ScanMirrorTemperature"]["FCUNominalScanMirrorSensor2Temp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 - bbdu["BBRelatedData"]["ScanMirrorTemperature"]["FCURedundantScanMirrorSensor2Temp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 + bbdu["BBRelatedData"]["ScanMirrorTemperature"][ + "FCUNominalScanMirrorSensor1Temp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 + bbdu["BBRelatedData"]["ScanMirrorTemperature"][ + "FCURedundantScanMirrorSensor1Temp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 + bbdu["BBRelatedData"]["ScanMirrorTemperature"][ + "FCUNominalScanMirrorSensor2Temp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 + bbdu["BBRelatedData"]["ScanMirrorTemperature"][ + "FCURedundantScanMirrorSensor2Temp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 bbdu["BBRelatedData"]["M1M2M3Temperature"] = {} - bbdu["BBRelatedData"]["M1M2M3Temperature"]["FCUNominalM1MirrorSensor1Temp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 - bbdu["BBRelatedData"]["M1M2M3Temperature"]["FCURedundantM1MirrorSensor1Temp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 - bbdu["BBRelatedData"]["M1M2M3Temperature"]["FCUNominalM1MirrorSensor2Temp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 - bbdu["BBRelatedData"]["M1M2M3Temperature"]["FCURedundantM1MirrorSensor2Temp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 - bbdu["BBRelatedData"]["M1M2M3Temperature"]["FCUNominalM23AssemblySensor1Temp"] = ord(fp.read(1)) / 4. + 265 - bbdu["BBRelatedData"]["M1M2M3Temperature"]["FCURedundantM23AssemblySensor1Temp"] = ord(fp.read(1)) / 4. + 265 - bbdu["BBRelatedData"]["M1M2M3Temperature"]["FCUNominalM23AssemblySensor2Temp"] = ord(fp.read(1)) / 4. + 265 - bbdu["BBRelatedData"]["M1M2M3Temperature"]["FCURedundantM23AssemblySensor2Temp"] = ord(fp.read(1)) / 4. + 265 + bbdu["BBRelatedData"]["M1M2M3Temperature"][ + "FCUNominalM1MirrorSensor1Temp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 + bbdu["BBRelatedData"]["M1M2M3Temperature"][ + "FCURedundantM1MirrorSensor1Temp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 + bbdu["BBRelatedData"]["M1M2M3Temperature"][ + "FCUNominalM1MirrorSensor2Temp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 + bbdu["BBRelatedData"]["M1M2M3Temperature"][ + "FCURedundantM1MirrorSensor2Temp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 + bbdu["BBRelatedData"]["M1M2M3Temperature"][ + "FCUNominalM23AssemblySensor1Temp"] = ord(fp.read(1)) / 4. + 265 + bbdu["BBRelatedData"]["M1M2M3Temperature"][ + "FCURedundantM23AssemblySensor1Temp"] = ord(fp.read(1)) / 4. + 265 + bbdu["BBRelatedData"]["M1M2M3Temperature"][ + "FCUNominalM23AssemblySensor2Temp"] = ord(fp.read(1)) / 4. + 265 + bbdu["BBRelatedData"]["M1M2M3Temperature"][ + "FCURedundantM23AssemblySensor2Temp"] = ord(fp.read(1)) / 4. + 265 bbdu["BBRelatedData"]["BaffleTemperature"] = {} - bbdu["BBRelatedData"]["BaffleTemperature"]["FCUNominalM1BaffleTemp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 - bbdu["BBRelatedData"]["BaffleTemperature"]["FCURedundantM1BaffleTemp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 + bbdu["BBRelatedData"]["BaffleTemperature"][ + "FCUNominalM1BaffleTemp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 + bbdu["BBRelatedData"]["BaffleTemperature"][ + "FCURedundantM1BaffleTemp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 bbdu["BBRelatedData"]["BlackBodyTemperature"] = {} - bbdu["BBRelatedData"]["BlackBodyTemperature"]["FCUNominalBlackBodySensorTemp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 - bbdu["BBRelatedData"]["BlackBodyTemperature"]["FCURedundantBlackBodySensorTemp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 + bbdu["BBRelatedData"]["BlackBodyTemperature"][ + "FCUNominalBlackBodySensorTemp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 + bbdu["BBRelatedData"]["BlackBodyTemperature"][ + "FCURedundantBlackBodySensorTemp"] = rbin.read_uint2(fp.read(2)) / 100. + 250 bbdu["BBRelatedData"]["FCUMode"] = {} - bbdu["BBRelatedData"]["FCUMode"]["FCUNominalSMMStatus"] = rbin.read_uint2(fp.read(2)) - bbdu["BBRelatedData"]["FCUMode"]["FCURedundantSMMStatus"] = rbin.read_uint2(fp.read(2)) + bbdu["BBRelatedData"]["FCUMode"][ + "FCUNominalSMMStatus"] = rbin.read_uint2(fp.read(2)) + bbdu["BBRelatedData"]["FCUMode"][ + "FCURedundantSMMStatus"] = rbin.read_uint2(fp.read(2)) extracted_data_type = np.dtype([('NumberOfPixelsUsed', '>u4'), ('MeanCount', '>f4'), ('RMS', '>f4'), @@ -810,7 +855,8 @@ def read_metadata(prologue, image_files, epilogue): im = _xrit.read_imagedata(image_files[0]) md = Metadata() - md.calibrate = _Calibrator(hdr, im.product_name, bits_per_pixel=im.structure.nb) + md.calibrate = _Calibrator( + hdr, im.product_name, bits_per_pixel=im.structure.nb) md.sublon = hdr["ProjectionDescription"]["LongitudeOfSSP"] md.product_name = im.product_id @@ -842,7 +888,8 @@ def read_metadata(prologue, image_files, epilogue): md.coff = (ftr["Lower" + ew_.capitalize() + "ColumnActual"] + im.navigation.coff + 1) - md.loff = im.navigation.loff + segment_size * (im.segment.seg_no - 1) + 2 + md.loff = im.navigation.loff + \ + segment_size * (im.segment.seg_no - 1) + 2 else: md.first_pixel = hdr["ReferenceGridVIS_IR"]["GridOrigin"] diff --git a/mipp/xrit/sat.py b/mipp/xrit/sat.py index 276d847..3e49a84 100644 --- a/mipp/xrit/sat.py +++ b/mipp/xrit/sat.py @@ -1,21 +1,24 @@ # # $Id$ # -import numpy import glob import imp -import types +import logging +import os import re +import types +from datetime import timedelta -import logging -logger = logging.getLogger('mipp') +import numpy +import six import mipp import mipp.cfg from mipp.xrit import _xrit from mipp.xrit.loader import ImageLoader -import os -from datetime import timedelta + +logger = logging.getLogger('mipp') + __all__ = ['load_meteosat07', 'load_meteosat09', @@ -34,6 +37,7 @@ CHECK_CONFIG_SUBLON = False _xrit.header_map = _xrit.base_header_map _xrit.header_types = _xrit.base_header_types + class SatelliteLoader(object): # Currently this one only works for geos satellites # @@ -50,7 +54,8 @@ class SatelliteLoader(object): sat = config_reader('satellite') projname = sat['projection'].lower() if not projname.startswith('geos'): - raise mipp.ReaderError("currently we only support projections of type: 'GEOS'") + raise mipp.ReaderError( + "currently we only support projections of type: 'GEOS'") # # Load format decoder based on level1 format @@ -117,7 +122,8 @@ class SatelliteLoader(object): val["segment"] = "PRO".ljust(9, '_') filename_pro = opt.get('filename_pro', opt['filename']) - prologue = glob.glob(start_time.strftime(os.path.join(opt['dir'], filename_pro)) % val) + prologue = glob.glob(start_time.strftime( + os.path.join(opt['dir'], filename_pro)) % val) if not prologue: logger.info("No prologue file to read.") @@ -133,11 +139,13 @@ class SatelliteLoader(object): dt = timedelta(minutes=1) image_files = [] while start_time <= end_time: - image_files.extend(glob.glob(start_time.strftime(os.path.join(opt['dir'], opt['filename'])) % val)) + image_files.extend(glob.glob(start_time.strftime( + os.path.join(opt['dir'], opt['filename'])) % val)) start_time += dt if not image_files: - raise mipp.NoFiles("no data files: '%s'" % (start_time.strftime(opt['filename']) % val)) + raise mipp.NoFiles("no data files: '%s'" % + (start_time.strftime(opt['filename']) % val)) image_files.sort() # Check if the files are xrit-compressed, and decompress them @@ -172,7 +180,8 @@ class SatelliteLoader(object): def _read_metadata(self, prologue, image_files, epilogue=None): if epilogue: - mda = self._metadata_reader(prologue, image_files, epilogue=epilogue) + mda = self._metadata_reader( + prologue, image_files, epilogue=epilogue) else: mda = self._metadata_reader(prologue, image_files) if "%.2f" % mda.sublon != "%.2f" % self.sublon: @@ -180,8 +189,8 @@ class SatelliteLoader(object): raise mipp.ReaderError("Sub satellite point in config file (%.2f) don't match data (%.2f)" % (self.sublon, mda.sublon)) else: - logger.warning("Modifying sub satellite point from %.2f to %.2f" % - (self.sublon, mda.sublon)) + logger.warning("Modifying sub satellite point from %.2f to %.2f", + self.sublon, mda.sublon) self.sublon = mda.sublon try: @@ -194,7 +203,8 @@ class SatelliteLoader(object): raise mipp.ReaderError("unknown image width for %s, %s: %d" % (self.satname, mda.channel, mda.image_size[0])) - mda.pixel_size = numpy.array([chn.resolution, chn.resolution], dtype=numpy.float64) + mda.pixel_size = numpy.array( + [chn.resolution, chn.resolution], dtype=numpy.float64) for k, v in self.__dict__.items(): if k[0] != '_' and type(v) != types.FunctionType: setattr(mda, k, v) @@ -208,7 +218,8 @@ class SatelliteLoader(object): mda = self._read_metadata(prologue, image_files, epilogue=epilogue) else: mda = self._read_metadata(prologue, image_files) - len_img = (((mda.image_size[0] + mda.line_offset) * mda.image_size[1]) * abs(mda.data_type)) // 8 + len_img = (((mda.image_size[0] + mda.line_offset) + * mda.image_size[1]) * abs(mda.data_type)) // 8 logger.info("Data size: %dx%d pixels, %d bytes, %d bits per pixel", mda.image_size[0], mda.image_size[1], len_img, abs(mda.data_type)) @@ -277,13 +288,16 @@ def decompress(infiles, **options): def load_files(prologue, image_files, epilogue=None, **kwarg): - if type(prologue) == type('string'): - logger.info("Read %s" % prologue) + if isinstance(prologue, (str, six.text_type)): + logger.info("Read %s", prologue) prologue = _xrit.read_prologue(prologue) - if epilogue and type(epilogue) == type('string'): - logger.info("Read %s" % epilogue) + if epilogue and isinstance(epilogue, (str, six.text_type)): + logger.info("Read %s", epilogue) epilogue = _xrit.read_epilogue(epilogue) - satname = prologue.platform.lower() + + satname = kwarg.pop('platform_name', None) + if satname is None: + satname = prologue.platform return SatelliteLoader(mipp.cfg.read_config(satname)).load_files(prologue, image_files, epilogue=epilogue, diff --git a/mipp/xsar/S1A.py b/mipp/xsar/S1A.py index d41d034..c85ebd9 100644 --- a/mipp/xsar/S1A.py +++ b/mipp/xsar/S1A.py @@ -12,7 +12,6 @@ from datetime import datetime from mipp.xsar import Metadata -SATELLITE = 's1a' PIXEL_SPACING = { 'sm-f': (4, 4), 'sm-h': (10, 10), @@ -178,7 +177,7 @@ def read_manifest(filename, **mdax): resolution = manifest.resolution_class channels = {} for pol in manifest.polarisations: - _text = '-'.join([SATELLITE, manifest.instrument_mode, manifest.product_type, pol]) + _text = '-'.join([manifest.mission_id, manifest.instrument_mode, manifest.product_type, pol]) _name = '-'.join([manifest.instrument_mode, resolution, pol]) for fn in manifest.files: if os.path.basename(fn).startswith(_text): diff --git a/setup.py b/setup.py index c06e482..4a79bf9 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ # Author(s): -# Lars Orum Rasmussen <[email protected]> +# Lars Orum Rasmussen <[email protected]> # This file is part of mipp. @@ -26,13 +26,13 @@ """Setup file for mipp. """ -import os -from setuptools import setup, Extension import imp +from setuptools import setup + version = imp.load_source('mipp.version', 'mipp/version.py') -setup(name = 'mipp', +setup(name='mipp', description='Meteorological ingest processing package', author='Lars Orum Rasmussen', author_email='[email protected]', @@ -43,8 +43,10 @@ setup(name = 'mipp', "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Scientific/Engineering"], - url="https://github.com/loerum/mipp", - version = version.__version__, - packages = ['mipp', 'mipp.xrit', 'mipp.xsar'], - zip_safe = False, + url="https://github.com/pytroll/mipp", + download_url="https://github.com/pytroll/mipp/releases/tag/" + version.__version__, + version=version.__version__, + install_requires=['six', 'numpy'], + packages=['mipp', 'mipp.xrit', 'mipp.xsar'], + zip_safe=False, ) diff --git a/tests/data/MSG2_HRV_20101011_1400.mda b/tests/data/MSG2_HRV_20101011_1400.mda index 2a0fc33..2fda0c5 100644 --- a/tests/data/MSG2_HRV_20101011_1400.mda +++ b/tests/data/MSG2_HRV_20101011_1400.mda @@ -1,4 +1,4 @@ -area_extent: [-501567.37595780345, -198526.6682504965, 498566.97291119647, 401553.9410709035] +area_extent: [-499567.1072600655, -200526.93694823448, 500567.24160893448, 399553.67237316549] calibration_unit: % channel: HRV data_type: 64 diff --git a/tests/data/MSG2_HRV_20101109_1200.mda b/tests/data/MSG2_HRV_20101109_1200.mda index ad6ff18..ceb7889 100644 --- a/tests/data/MSG2_HRV_20101109_1200.mda +++ b/tests/data/MSG2_HRV_20101109_1200.mda @@ -1,4 +1,4 @@ -area_extent: [-4822147.7630718835, 2333813.5030858112, 4177061.1080513783, 2783873.9600768615] +area_extent: [-4820147.4943741448, 2331813.2343880734, 4179061.3767491165, 2781873.6913791234] calibration_unit: % channel: HRV data_type: 64 -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/mipp.git _______________________________________________ Pkg-grass-devel mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel

