Skip to content

Instantly share code, notes, and snippets.

View ougx's full-sized avatar

Michael Ou@SSPA ougx

View GitHub Profile
#This script is developed by Gengxin (Michael) Ou on 2/18/2015
#This script require the package dataRetrieval, hydroGOF and ggplot2.
#The purpose of this script is to plot the SWAT results and compared it with USGS data.
#load the packages
library("dataRetrieval")
library("ggplot2")
library("hydroGOF")
@ougx
ougx / PEST_CN.r
Last active August 29, 2015 14:16
Create the SWAT files for PEST
# Produced by Michael Ou, 2/11/2015
# using PEST for SWAT calibration
# grouping the same parameter for all HRUs
# change of parameter is accommodated by multiplying a relative rate which is operated by PEST
# for uniform parameters (same value for all HRUs), we replace it directly.
# observations are donwloaded automatically from USGS
# r__CN2.mgt -0.2 0.2
# v__ALPHA_BF.gw 0.0 1.0
# v__GW_DELAY.gw 30.0 450.0
@ougx
ougx / Raster_NDVI.r
Last active August 29, 2015 14:17
flip NDVI
library(raster)
flipMaxMin <-function(vin){
n = length(vin)
nrw=nrow(vin)
#eleminate the null values
v <- na.omit(as.vector(vin))
#length of the vector after elemination of null
nn =length(v)
#the regular rank
"""
Created on Thu May 12 01:34:06 2016
@author: Michael
"""
%matplotlib inline
import cartopy.crs as ccrs
import cartopy.feature as cfeature
import cartopy
import matplotlib
@ougx
ougx / fortran-formatter.py
Created June 12, 2016 05:55
A python script to format fortran codes
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 11 03:14:20 2016
A python script to format fortran codes including:
1) separate miltiple-variable declaration so each line only contain one varaible
2) lower all the fortran keywords
3) automatically indent
Inputs:
n_indent -- number of spaces for each indention

Preprocessing

Forcing data

Disaggregation

The forcing data is generated based on the 1/16 degree Livneh forcing dataset. The original Livneh dataset is obtained at HYDRA:/raid/blivneh/forcings/outputs/CONUS/asc.v.1.2.b/data_${latitude}_${longitude}. A copy of the data has been placed at HYAK:/civil/hydro/michaelou/summaProj/summaData/blivneh/asc.v.1.2.b. The daily forcing data is disaggregated to a hourly basis by running VIC_4.1.2. The results of disaggregation are placed at HYAK:/civil/hydro/michaelou/summaProj/summaData/blivneh/workdir.

Converting to SUMMA inputs
@ougx
ougx / UNL-HydroMet-text2nc.md
Last active April 28, 2017 00:53
Procedure to convert VIC output from the ascii file format to the netcdf file format

We are going to use xarray instead of ScentificPython to generate netcdf file. The reason of doing so is that ScientificPython is obsolete.

Step 1. Activate Anaconda

Anaconda: https://www.continuum.io/Anaconda-Overview

To load Anaconda on our cluster:

module load anaconda
@ougx
ougx / OOP_F2003_Part_1.md
Created May 26, 2017 20:27 — forked from n-s-k/OOP_F2003_Part_1.md
Object-Oriented Programming in Fortran 2003 Part 1: Code Reusability
@ougx
ougx / OOP_F2003_Part_2.md
Created May 26, 2017 20:28 — forked from n-s-k/OOP_F2003_Part_2.md
Object-Oriented Programming in Fortran 2003 Part 2: Data Polymorphism

Object-Oriented Programming in Fortran 2003 Part 2: Data Polymorphism

Original article by Mark Leair, PGI Compiler Engineer

Note: This article was revised in March 2015 and again in January 2016 to bring it up-to-date with the production software release and to correct errors in the examples.

This is Part 2 of a series of articles:

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.