Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to convert VIC 4.2 ascii state files to VIC 5.0 netcdf #66

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,25 @@ python:
- "2.7"
- "3.4"

# Setup anaconda
# Set up anaconda
before_install:
- wget http://repo.continuum.io/miniconda/Miniconda-2.2.2-Linux-x86_64.sh -O miniconda.sh
- chmod +x miniconda.sh
- ./miniconda.sh -b
- export PATH=/home/travis/anaconda/bin:$PATH
# Example yml file didn't set sudo to false above,
# and had the next line uncommented
# - sudo apt-get update
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O miniconda.sh;
else
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
fi
- bash miniconda.sh -b -p $HOME/miniconda
# - chmod +x miniconda.sh
# - ./miniconda.sh -b -p $HOME/miniconda
- export PATH=$HOME/miniconda/bin:$PATH
- hash -r
# Update conda itself
- conda update --yes conda

- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
- conda info -a
install:
- conda create --yes --name=tonic_test_env python=$TRAVIS_PYTHON_VERSION --file=ci/requirements-$TRAVIS_PYTHON_VERSION.txt
- source activate tonic_test_env
Expand Down
206 changes: 182 additions & 24 deletions scripts/vic_utils
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ def main():

# ---------------------------------------------------------------- #
# create the parser for the "netcdf2vic" command
netcdf2vic_parser = subparsers.add_parser('netcdf2vic',
help=netcdf2vic.help,
description=netcdf2vic.description)
netcdf2vic_parser \
= subparsers.add_parser('netcdf2vic',
help=netcdf2vic.help,
description=netcdf2vic.description)
netcdf2vic_parser.set_defaults(func=netcdf2vic._run)
netcdf2vic_parser.add_argument("config",
type=str,
Expand All @@ -41,9 +42,10 @@ def main():

# ---------------------------------------------------------------- #
# create the parser for the "grid_params" command
grid_params_parser = subparsers.add_parser('grid_params',
help=grid_params.help,
description=grid_params.description)
grid_params_parser \
= subparsers.add_parser('grid_params',
help=grid_params.help,
description=grid_params.description)
grid_params_parser.set_defaults(func=grid_params._run)
grid_params_parser.add_argument("soil_file",
type=str,
Expand All @@ -59,37 +61,190 @@ def main():
"elevation band data in standard VIC "
"format",
default=None)
grid_params_parser.add_argument("-b", "--vegl_file",
type=str,
help="Input file containing vegetation "
"library data in"
" standard VIC format",
default=None)
grid_params_parser.add_argument("-v", "--veg_file",
type=str,
help="Input file containing vegitation "
help="Input file containing vegetation "
"parameter data "
"in standard VIC format",
default=None)
grid_params_parser.add_argument("-l", "--vegl_file",
grid_params_parser.add_argument("-l", "--lake_file",
type=str,
help="Input file containing vegitation "
"library data in"
" standard VIC format",
help="Input file containing lake "
"parameter data "
"in standard VIC format",
default=None)
grid_params_parser.add_argument("-s", "--state_file",
type=str,
help="Input file containing model "
"state data "
"in standard VIC format",
default=None)
grid_params_parser.add_argument("-o", "--out_file",
type=str,
help="Output file name, "
help="Output file name "
"(default=/params.nc)",
default='params.nc')

grid_params_parser.add_argument("-t", "--out_state_file",
type=str,
help="Output state file name "
"(default=/state.nc)",
default=None)
grid_params_parser.add_argument("--VIC_version",
type=str,
help="VIC version to write parameter file "
"for",
choices=['4.1.2', '5.0.dev'],
default='4.1.2')
choices=['4.1.2', '4.2', '5.0.dev'],
default='4.2')
grid_params_parser.add_argument("-d", "--grid_decimal",
type=str,
help="Number of decimal places in "
"grid cell center lat/lon "
"coordinates (default=4)",
default=4)
grid_params_parser.add_argument("--nlayers",
type=str,
help="Number of soil layers "
"(default=3)",
default=3)
grid_params_parser.add_argument("--snow_bands",
type=str,
help="Number of snow bands "
"(default=1)",
default=1)
grid_params_parser.add_argument("--veg_classes",
type=str,
help="Number of veg classes "
"(default=11)",
default=11)
grid_params_parser.add_argument("--max_roots",
type=str,
help="Number of root zones "
"(default=3)",
default=3)
grid_params_parser.add_argument("--max_numnod",
type=str,
help="Max number of lake nodes "
"(default=10)",
default=10)
grid_params_parser.add_argument("--soil_nodes",
type=str,
help="Number of soil thermal nodes "
"(default=3)",
default=3)
grid_params_parser.add_argument("--nfrost",
type=str,
help="Number of spatial frost "
"zones (default=1)",
default=1)
grid_params_parser.add_argument("--cells",
type=str,
help="Number of cells "
"(default=determine from "
"input files)",
default=None)
grid_params_parser.add_argument("--organic_fract",
action='store_true',
help="Flag indicating whether soil "
"parameter file contains organic "
"fractions (default=False)")
grid_params_parser.add_argument("--spatial_frost",
action='store_true',
help="Flag indicating whether soil "
"parameter file contains spatial "
"frost parameters (default=False)")
grid_params_parser.add_argument("--spatial_snow",
action='store_true',
help="Flag indicating whether soil "
"parameter file contains spatial "
"snow parameters (default=False)")
grid_params_parser.add_argument("--july_tavg_supplied",
action='store_true',
help="Flag indicating whether soil "
"parameter file contains July "
"average temperature "
"(default=False)")
grid_params_parser.add_argument("--veglib_photo",
action='store_true',
help="Flag indicating whether veg "
"library file contains photo-"
"synthesis parameters "
"(default=False)")
grid_params_parser.add_argument("--veglib_fcan",
action='store_true',
help="Flag indicating whether veg "
"library file contains fcanopy "
"values (default=False)")
grid_params_parser.add_argument("--blowing_snow",
action='store_true',
help="Flag indicating whether veg "
"parameter file contains blowing "
"snow parameters (default=False)")
grid_params_parser.add_argument("--vegparam_lai",
action='store_true',
help="Flag indicating whether veg "
"parameter file contains lai "
"values (default=False)")
grid_params_parser.add_argument("--vegparam_fcan",
action='store_true',
help="Flag indicating whether veg "
"parameter file contains fcanopy "
"values (default=False)")
grid_params_parser.add_argument("--vegparam_albedo",
action='store_true',
help="Flag indicating whether veg "
"parameter file contains albedo "
"values (default=False)")
grid_params_parser.add_argument("--lai_src",
type=str,
help="Where to take lai values from; "
"can be one of: \'FROM_VEGLIB\', "
"\'FROM_VEGPARAM\' "
"(default=\'FROM_VEGLIB\')",
choices=['FROM_VEGLIB', 'FROM_VEGPARAM'],
default="FROM_VEGLIB")
grid_params_parser.add_argument("--fcan_src",
type=str,
help="Where to take fcanopy values from; "
"can be one of: \'FROM_DEFAULT\', "
"\'FROM_VEGLIB\', \'FROM_VEGPARAM\'; "
"\'FROM_DEFAULT\' = set them to 1.0; "
"(default=\'FROM_DEFAULT\')",
choices=['FROM_DEFAULT',
'FROM_VEGLIB', 'FROM_VEGPARAM'],
default="FROM_DEFAULT")
grid_params_parser.add_argument("--alb_src",
type=str,
help="Where to take albedo values from; "
"can be one of: \'FROM_VEGLIB\', "
"\'FROM_VEGPARAM\' "
"(default=\'FROM_VEGLIB\')",
choices=['FROM_VEGLIB', 'FROM_VEGPARAM'],
default="FROM_VEGLIB")
grid_params_parser.add_argument("--lake_profile",
action='store_true',
help="Flag indicating whether lake "
"parameter file contains lake "
"depth-area relationship "
"(default=False)")
grid_params_parser.add_argument("--carbon",
action='store_true',
help="Flag indicating whether state "
"file contains carbon-cycle "
"variables (default=False)")
# ---------------------------------------------------------------- #

# ---------------------------------------------------------------- #
# create the parser for the "ncparam2ascii" command
ncparam2ascii_parser = subparsers.add_parser('ncparam2ascii',
help=ncparam2ascii.help,
description=ncparam2ascii.description)
ncparam2ascii_parser \
= subparsers.add_parser('ncparam2ascii',
help=ncparam2ascii.help,
description=ncparam2ascii.description)
ncparam2ascii_parser.set_defaults(func=ncparam2ascii._run)
ncparam2ascii_parser.add_argument("nc_params",
type=str,
Expand Down Expand Up @@ -139,9 +294,10 @@ def main():

# ---------------------------------------------------------------- #
# create the parser for the "compare_soil_params" command
compare_soil_params_parser = subparsers.add_parser('compare_soil_params',
help=compare_soil_params.help,
description=compare_soil_params.description)
compare_soil_params_parser \
= subparsers.add_parser('compare_soil_params',
help=compare_soil_params.help,
description=compare_soil_params.description)
compare_soil_params_parser.set_defaults(func=compare_soil_params._run)

compare_soil_params_parser.add_argument("-d", "--domain_file",
Expand Down Expand Up @@ -175,9 +331,10 @@ def main():

# ---------------------------------------------------------------- #
# create the parser for the "vic2netcdf" command
vic2netcdf_parser = subparsers.add_parser('vic2netcdf',
help=vic2netcdf.help,
description=vic2netcdf.description)
vic2netcdf_parser \
= subparsers.add_parser('vic2netcdf',
help=vic2netcdf.help,
description=vic2netcdf.description)
vic2netcdf_parser.set_defaults(func=vic2netcdf._run)
vic2netcdf_parser.add_argument("config_file",
type=str,
Expand Down Expand Up @@ -216,6 +373,7 @@ def complete_subparser_action(prefix, **kwargs):
return internal_actions + external_actions
# -------------------------------------------------------------------- #


# -------------------------------------------------------------------- #
if __name__ == "__main__":
main()
Expand Down
Loading