Use reflectance data from datasets to generate simulated true colour plots.
This script needs emsarray
, matplotlib
and scipy
installed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import emsarray | |
from matplotlib import pyplot as plt | |
import numpy | |
import shapely | |
# Open a dataset | |
# This dataset starts with four dimensions: time, depth, and two surface dimensions | |
dataset = emsarray.open_dataset("https://dapds00.nci.org.au/thredds/dodsC/fx3/GBR1_H2p0_B3p2_Cfur_Dnrt.ncml") | |
# We can speed up future operations by limiting the timesteps |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import emsarray | |
import pandas | |
import shapely | |
# Open the dataset | |
gbr4 = emsarray.open_dataset('https://dapds00.nci.org.au/thredds/dodsC/fx3/model_data/gbr4_bgc_GBR4_H2p0_B2p0_Chyd_Dcrt.ncml') | |
# Define the area of interest | |
point = shapely.Point(152.384000, -22.672241) | |
circle = shapely.buffer(point, 0.1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
from functools import wraps | |
from flask import Response, make_response, request | |
from werkzeug.http import parse_date | |
def check_empty_iterator(iterator, message="Iterator was not empty"): | |
try: | |
next(iterator) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fcntl | |
import os | |
from contextlib import contextmanager | |
MODE_NAMES = { | |
fcntl.LOCK_SH: 'shared', | |
fcntl.LOCK_EX: 'exclusive', | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import chain, islice | |
class splitter: | |
"""Helper class for splitat.""" | |
def __init__(self, iterable, count): | |
self.iterator = iter(iterable) | |
self.count = count | |
self.queue = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Get the next/previous items in a queryset in relation to a reference object. | |
""" | |
from django.db.models import Q | |
def next_in_order(queryset, reference): | |
""" | |
Get the next items in a QuerySet according to its ordering, in relation to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _nested_form_data(data): | |
if isinstance(data, dict): | |
items = data.items() | |
elif isinstance(data, list): | |
items = enumerate(data) | |
for key, value in items: | |
key = str(key) | |
if isinstance(value, (dict, list)): | |
for child_keys, child_value in _nested_form_data(value): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Comparator(): | |
"""Support 'partial binding' of built in operators.""" | |
def __call__(self, a): | |
"""For support of nested PendingOperations, comparator(a) == a""" | |
return a | |
# A bunch of boring operators | |
def __lt__(self, b): | |
return PendingOperation(lambda a: self(a) < b) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.exceptions import ValidationError | |
from django import forms | |
class UsernameValidatorForm(forms.Form): | |
username = forms.CharField() | |
def clean_username(self): | |
username = self.cleaned_data['username'] |
NewerOlder