Skip to content

Commit

Permalink
Merge branch 'tc-dat' into clean
Browse files Browse the repository at this point in the history
  • Loading branch information
wcarthur committed Sep 11, 2015
2 parents 7b58a38 + 0221154 commit 06c1772
Show file tree
Hide file tree
Showing 14 changed files with 949 additions and 806 deletions.
43 changes: 29 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,44 @@
language: python
python:
- "2.7"
# install system dependencies
before_install:
- sudo apt-get update -qq
- sudo apt-get install build-essential
- sudo apt-get install libhdf5-serial-dev
- sudo apt-get install libnetcdf-dev
- sudo apt-get install python-dev
- sudo apt-get install libgeos-c1 libgeos-dev
- sudo apt-get install libatlas-base-dev gfortran
- sudo apt-get install libblas3gf libc6 libgcc1 libgfortran3 liblapack3gf libumfpack5.4.0 libstdc++6

sudo: false

addons:
apt:
packages:
- build-essential
- libgeos-c1
- lib-geos-dev
- libhdf5-serial-dev
- libatlas-base-dev
- gfortran
- libnetcdf-dev
- libblas3gf
- libc6
- libgcc1
- libgfortran3
- liblapack3gf
- libumfpack5.4.0
- libstdc++6

# install Python dependencies
install:
- sudo pip install conda
- sudo conda init
- pip install conda
- conda init
- deps='pip numpy scipy matplotlib basemap shapely nose coverage'
- conda create -p $HOME/py --yes $deps "python=$TRAVIS_PYTHON_VERSION"
- export PATH=$HOME/py/bin:$PATH
- if [[ $TRAVIS_PYTHON_VERSION == 2.6 ]]; then pip install ordereddict; fi
- pip install pycurl
- pip -v install -r requirements.txt
- pip install coveralls

# Script execution
script:
- python installer/setup.py build_ext -i
- nosetests -w tests/ -v --with-coverage
after_success:

# Post
after_success:
coveralls

704 changes: 0 additions & 704 deletions LICENSE

This file was deleted.

649 changes: 649 additions & 0 deletions LICENSE.rst

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,14 @@ Screenshot

.. image:: https://rawgithub.com/GeoscienceAustralia/tcrm/master/docs/screenshot.png

Contributing to TCRM
====================

If you would like to take part in TCRM development, take a look at `docs/contributing.rst <https://github.com/GeoscienceAustralia/tcrm/blob/master/docs/contributing.rst>`_.

License information
===================

See the file `LICENSE.rst <https://github.com/GeoscienceAustralia/tcrm/blob/master/LICENSE.rst>`_
for information on the history of this software, terms and conditions for usage,
and a DISCLAIMER OF ALL WARRANTIES.
2 changes: 1 addition & 1 deletion TrackGenerator/TrackGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1703,7 +1703,7 @@ def run(configFile, callback=None):
trackFile = pjoin(trackPath, sim.outfile)
tracks = tg.generateTracks(sim.ntracks, sim.index)
ncTrackFile = pjoin(trackPath, "tracks.{0:05d}.nc".format(sim.index))
ncSaveTracks(ncTrackFile, tracks)
ncSaveTracks(ncTrackFile, tracks, calendar='julian')

log.info('Simulating tropical cyclone tracks:' +
' 100 percent complete')
Expand Down
39 changes: 14 additions & 25 deletions Utilities/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@
"""

import os
from os.path import join as pjoin
import logging

from Utilities.files import flGetStat, flModDate

global GLOBAL_DATFILE
global GLOBAL_PROCFILES
global GLOBAL_ARCHDIR
global GLOBAL_TIMESTAMP
global GLOBAL_DATEFMT
LOGGER = logging.getLogger()

GLOBAL_DATFILE = None
GLOBAL_PROCFILES = {}
GLOBAL_ARCHDIR = ''
GLOBAL_DATEFMT = '%Y%m%d%H%M'
Expand All @@ -41,7 +38,6 @@ def pSetProcessedEntry(directory, filename, attribute, value):
"""

global GLOBAL_DATFILE
global GLOBAL_PROCFILES
if directory in GLOBAL_PROCFILES:
if filename in GLOBAL_PROCFILES[directory]:
Expand All @@ -67,8 +63,6 @@ def pGetProcessedEntry(directory, filename, attribute):
"""

global GLOBAL_DATFILE
global GLOBAL_PROCFILES
try:
value = GLOBAL_PROCFILES[directory][filename][attribute]
rc = value
Expand All @@ -91,16 +85,14 @@ def pGetProcessedFiles(datFileName=None):
"""

global GLOBAL_DATFILE
global GLOBAL_PROCFILES
rc = 0
if datFileName:
GLOBAL_DATFILE = datFileName
try:
fh = open(datFileName)

except IOError:
LOGGER.warn("Couldn't open dat file %s",
(datFileName))
LOGGER.warn("Couldn't open dat file %s", datFileName)
return rc
else:
LOGGER.debug("Getting previously-processed files from %s",
Expand All @@ -117,8 +109,8 @@ def pGetProcessedFiles(datFileName=None):

else:
LOGGER.info("No dat file name provided - all files will be processed")

return rc

return rc

def pWriteProcessedFile(filename):
Expand All @@ -134,14 +126,13 @@ def pWriteProcessedFile(filename):
"""
global GLOBAL_DATFILE
global GLOBAL_PROCFILES
rc = 0
if GLOBAL_DATFILE:
directory, fname, md5sum, moddate = flGetStat(filename)
try:
fh = open(GLOBAL_DATFILE, 'a')
except IOError:
LOGGER.info("Cannot open %s"%(GLOBAL_DATFILE))
LOGGER.info("Cannot open %s", GLOBAL_DATFILE)

else:
pSetProcessedEntry(directory, fname, 'md5sum', md5sum)
Expand All @@ -150,7 +141,8 @@ def pWriteProcessedFile(filename):
fh.close()
rc = 1
else:
LOGGER.warn("Dat file name not provided. Can't record %s as processed."%(filename))
LOGGER.warn(("Dat file name not provided. "
"Can't record %s as processed."), filename)

return rc

Expand All @@ -165,13 +157,11 @@ def pDeleteDatFile():
"""

global GLOBAL_DATFILE
global GLOBAL_PROCFILES
rc = 0
if os.unlink(GLOBAL_DATFILE):
rc = 1
else:
LOGGER.warn("Cannot remove dat file %s"%(GLOBAL_DATFILE))
LOGGER.warn("Cannot remove dat file %s", GLOBAL_DATFILE)
return rc

def pAlreadyProcessed(directory, filename, attribute, value):
Expand All @@ -190,7 +180,6 @@ def pAlreadyProcessed(directory, filename, attribute, value):
"""
global GLOBAL_DATFILE
global GLOBAL_PROCFILES
rc = False
if pGetProcessedEntry(directory, filename, attribute) == value:
rc = True
Expand Down Expand Up @@ -220,7 +209,7 @@ def pArchiveDir(archive_dir=None):
try:
os.makedirs(GLOBAL_ARCHDIR)
except:
LOGGER.exception("Cannot create %s"%(GLOBAL_ARCHDIR))
LOGGER.exception("Cannot create %s", GLOBAL_ARCHDIR)
raise OSError

rc = GLOBAL_ARCHDIR
Expand Down Expand Up @@ -279,10 +268,10 @@ def pMoveFile(origin, destination):
try:
os.rename(origin, destination)
except OSError:
LOGGER.warn("Error moving %s to %s"%(origin, destination))
LOGGER.warn("Error moving %s to %s", origin, destination)
rc = 0
else:
LOGGER.debug("%s moved to %s"%(origin, destination))
LOGGER.debug("%s moved to %s", origin, destination)
rc = 1

return rc
Expand All @@ -309,14 +298,14 @@ def pArchiveFile(filename):
try:
os.makedirs(archive_dir)
except OSError:
LOGGER.critcal("Cannot create %s"%(archive_dir))
LOGGER.critcal("Cannot create %s", archive_dir)
raise

if pArchiveTimestamp():
archive_date = flModDate(filename, GLOBAL_DATEFMT)
archive_file_name = os.path.join(archive_dir, "%s.%s.%s"%(base, archive_date, ext))
archive_file_name = pjoin(archive_dir, "%s.%s.%s"%(base, archive_date, ext))
else:
archive_file_name = os.path.join(archive_dir, "%s.%s"%(base, ext))
archive_file_name = pjoin(archive_dir, "%s.%s"%(base, ext))

rc = pMoveFile(filename, archive_file_name)
return rc
4 changes: 2 additions & 2 deletions Utilities/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,11 @@ def ncSaveTracks(trackfile, tracks,
t.data['Datetime'] = date2num(t.data['Datetime'], timeunits, calendar)
times[:] = t.data['Datetime']
times.units = 'hours since 1900-01-01 00:00'
times.calendar = 'standard'
times.calendar = calendar
tvar[:] = t.data.astype(track_dtype)
tvar.long_name = "Tropical cyclone track data"
tvar.time_units = 'hours since 1900-01-01 00:00'
tvar.calendar = 'standard'
tvar.calendar = calendar
tvar.lon_units = 'degrees east'
tvar.lat_units = 'degrees north'
tvar.pressure_units = 'hPa'
Expand Down
Loading

0 comments on commit 06c1772

Please sign in to comment.