Skip to content

Instantly share code, notes, and snippets.

@trondkr
trondkr / zip archive
Created April 19, 2014 21:02
Zip archive
#!/bin/bash
cd /Users/trondkr/Projects/Syncsolution/Archives
/usr/bin/zip -r Syncsolution-bamboobuild-${bamboo.buildNumber}.xarchive.zip Syncsolution-bamboobuild-${bamboo.buildNumber}.xarchive
echo "Finished creating ZIP file of archive"
@trondkr
trondkr / updatePod
Created April 13, 2015 19:22
Pod update Bamboo step 2
#!/bin/bash
cd ${bamboo.build.working.directory}
echo "Running pod install in directory: ${bamboo.build.working.directory}"
pod update
#!/bin/sh
# Script to extract the last time step of a netcdf file and add it again in the same
# file with a time step forward in time. This sort of fakes a later time-step in the file
#
# Trond Kristiansen, 10.08.2015, 22.09.2016 (NOWMAPS)
ncea -F -d ocean_time,20,20 nordsjoen_8km_bry_GLORYS_20130515_to_20141215.nc test.nc
ncap -O -s ocean_time=ocean_time+86400*14 test.nc siste.nc
ncatted -O -a units,ocean_time,c,c,"seconds since 1948-01-01 00:00:00" siste.nc tmp.nc
@trondkr
trondkr / automatedBuildAndUploadToTestflight.sh
Last active August 29, 2015 14:27 — forked from djacobs/automatedBuildAndUploadToTestflight.sh
Automated Xcode build and upload to TestFlight.
#!/bin/sh
# Current as working as of 2012/4/17
# Xcode 4.3.2
PROJECT_ROOT="$HOME/SomeDirWhereYourProjectLives/XXXXXXXX"
WORKSPACE="$PROJECT_ROOT/XXXXXXXX.xcodeproj/project.xcworkspace"
CONFIG="AdHoc"
SCHEME="XXXXXXXX"
ncra -v u,v,temp,salt,angle kino_1600m_{23011..23375}.nc average2011.nc
@trondkr
trondkr / gist:623bf4e6d16fb0dd5ceb11a99bbb1390
Last active December 6, 2016 08:28
Wget all files in URL using wildcard
wget -r --no-parent -A --no-clobber 'soda3.3.1_mn*.nc' http://dsrs.atmos.umd.edu/DATA/soda3.3.1/REGRIDED/
ncflint -A -C -v ubar_north,vbar_north,u_north,v_north,ubar_west,vbar_west,u_west,v_west -w 0.0,0.0 ws4km_bry_SODA3_19890115_to_20151215_test.nc ws4km_bry_SODA3_19890115_to_20151215_test.nc test.nc
@trondkr
trondkr / mergetime.py
Last active April 6, 2017 18:54
Remove duplicates of timesteps in netcdf files
```python
from netCDF4 import Dataset, datetime, date2num,num2date
import numpy as np
import os
from subprocess import call
__author__ = 'Trond Kristiansen'
__email__ = 'trond.kristiansen@niva.no'
__created__ = datetime(2017, 2, 1)
__modified__ = datetime(2017, 2, 1)
@trondkr
trondkr / seltimesteps.sh
Last active April 19, 2019 16:16
CDO seltimesteps
# Select the first 12 timesteps of a file
cdo -seltimestep,1/12 NORESM_ATM.cam2.hmlvl.2006-2100_delta.nc NORESM_ATM.cam2.hmlvl.2006-2100_delta.nc2
@trondkr
trondkr / deleteTimestepsInNetCDFfiles.py
Last active July 8, 2019 17:00
This script reads netcdf files and investigates whether some timesteps occurr more than one time.
import os
import datetime as datetime
from netCDF4 import Dataset
from subprocess import call
from itertools import chain
__author__ = 'Trond Kristiansen'
__email__ = 'me (at) trondkristiansen.com'
__created__ = datetime.datetime(2014, 4, 2)
__modified__ = datetime.datetime(2014, 4, 2)