Skip to content

Instantly share code, notes, and snippets.

View MiCurry's full-sized avatar

Miles Curry MiCurry

View GitHub Profile
from __future__ import absolute_import, division, print_function # Python 3 Support
import sys
from netCDF4 import Dataset
import numpy as np
if len(sys.argv) != 3: # Argument checking
print("Usage: python cellsOnCell.py meshFileName cell")
print("Please supply a mesh file and a cell number of your choosing")
sys.exit(-1)
@MiCurry
MiCurry / sphere_distance.py
Created October 10, 2019 20:21
Function to calculate a sphere distance
def sphere_distance(lat1, lon1, lat2, lon2, radius, **kwargs):
""" Calculate the sphere distance between point1 and point2.
lat1 - Float - Radians - -pi:pi
lon1 - Float - Radians - 0:2*pi
lat2 - Float - Radians - -pi:pi
lon2 - Float - Radians - 0:2*pi
radius - Radius of the earth (or sphere) - Units can be ignored
"""
@MiCurry
MiCurry / mpas_init_atm_core.F
Last active January 29, 2020 18:35
MPAS Init Atm Core with tests for mpas_stack.F
! Copyright (c) 2013, Los Alamos National Security, LLC (LANS)
! and the University Corporation for Atmospheric Research (UCAR).
!
! Unless noted otherwise source code is licensed under the BSD license.
! Additional copyright and license information can be found in the LICENSE file
! distributed with this code, or at http://mpas-dev.github.com/license.html
!
module init_atm_core
use mpas_stack
@MiCurry
MiCurry / mpas_init_atm_core.F
Last active July 13, 2020 16:27
MPAS Init Atm Core for testing the MPAS KD Tree
! Copyright (c) 2013, Los Alamos National Security, LLC (LANS)
! and the University Corporation for Atmospheric Research (UCAR).
!
! Unless noted otherwise source code is licensed under the BSD license.
! Additional copyright and license information can be found in the LICENSE file
! distributed with this code, or at http://mpas-dev.github.com/license.html
!
module init_atm_core
@MiCurry
MiCurry / changeCase.f90
Last active February 21, 2020 22:40
Fortran to Upper and To Lower
program case
implicit none
character(len=100) :: arg
call getarg(1,arg)
write(0,*) "capitalize: ", capitalize(arg)
write(0,*) "lowercase: ", lowercase(arg)
@MiCurry
MiCurry / index
Last active April 6, 2020 20:50
mpas_init_atm_core.F for mpas_parse_geoindex.F
#
# Boolean
#
signed=NO
#
# Integer
#
category_max=13
category_min = 1
filename_digits=5
@MiCurry
MiCurry / static_interp.F
Last active April 9, 2020 16:49
Static interpolation psuedocode
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! OG - Terrain static interpolation
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Name: temp
Type: channel
Upper-lat: 23.43676
Lower-lat: 66.33333
@MiCurry
MiCurry / timers.py
Created September 10, 2020 19:35
Simple Python Timers
import time
class PyTimers:
""" A small timer class in a similar vain as MPAS timers. Probably no the most efficent, but
its easy to use. """
def __init__(self):
self.timers = {}
def finalize(self):
@MiCurry
MiCurry / supersample.f90
Last active December 9, 2020 17:50
Supersample
program supersample_fac
implicit none
integer :: i, j, ii, jj
integer :: supersample
integer :: tile_nx, tile_ny
integer :: tile_bdr
real :: lat, lon, latp, lonp
real :: known_lat