Skip to content

Instantly share code, notes, and snippets.

View guziy's full-sized avatar
🇺🇦
#StandWithUkraine

Oleksandr Huziy guziy

🇺🇦
#StandWithUkraine
View GitHub Profile
# Example of the customization for the fortran highlighting
# To highlight fortran in GEM model
path = require 'path'
atom.workspace.observeTextEditors (editor) ->
if path.extname(editor.getPath()) in [".ftn", ".ftn90", ".cdk", ".cdk90", ".f"]
editor.setGrammar(atom.grammars.grammarForScopeName('source.fortran.modern'))
!Write temperature to a text file for debug
if (time_step == 1) then
write(line_format, "(I8)") G_ni
line_format = "(" // trim(line_format) // "F8.3)"
end if
write(debug_txt_filename, "(A3,I3.3,A4)") "TT_", time_step,
$ ".txt"
time_step = time_step + 1
# Example done with Kamel Chikhar on 9/03/2015
# frame1 - a frame from a file that does not contain levels and can have different number of levels for different dates
# and different number of dates for the same levels
# Create all possible multiindices
all_dates_unique = [start + i * day for i in range(ndays)]
all_levels_unique = list(reversed(np.unique(frame1["X.6"])))
all_hours_unique = [i * dt.seconds // 3600 for i in range(24 * 3600 // dt.seconds)]
@guziy
guziy / del_feb29.py
Created March 6, 2015 17:29
Delete Feb29 fields from a netcdf file
import os
from netCDF4 import Dataset, num2date
import calendar
import numpy as np
def del_feb29_in_file(in_path, varname):
#input file
dsin = Dataset(in_path)
if not os.path.isdir(varname):
watch -n 1 cat time.step
hdf5_lib=$(true_path ../hdf5-sf90/lib)
hdf5_include=$(true_path ../hdf5-sf90/include)
nc_lib=$(true_path ../netcdf4-sf90/lib)
nc_include=$(true_path ../netcdf4-sf90/include)
LIBS="-lnetcdf"
CFLAGS="-I${hdf5_include} -I${nc_include}"
LDFLAGS="-L${hdf5_lib} -L${nc_lib}"
@guziy
guziy / configure hdf5
Created February 17, 2015 01:18
configure for installing hdf5 used by netcdf4
set -x
CXX=s.cc CC=s.cc FC=s.f90 LD=s.f90 ./configure --prefix=$(true_path ../hdf5-sf90) --enable-fortran
make
make check
make install
import urllib2
import re
import os
#link format
url = "http://www.globsnow.info/se/archive_v2.1/{}/D4SC/"
#Year range of the data to be downloaded
start_year = 2003
end_year = 2003
@guziy
guziy / download.py
Last active August 29, 2015 14:14
Some script I've used to download snow extent data
import urllib2
import re
import os
url = "http://www.globsnow.info/se/archive_v2.1/{}/D4SC/"
start_year = 2003
end_year = 2003
for year in range(start_year, end_year + 1):
year_url = url.format(year)
#!/bin/bash
#This simple code demonstrates how to define a function, local and global variables in bash.
#And most importantly, how to launch background processes and wait for their termination
gvar="Glob value"
ncalls=0
avar="Test"
# Note for ksh users: in ksh to mark a function definition you should use either function keyword
# or () after the function name, not both
function a_proc(){