Skip to content

Instantly share code, notes, and snippets.

View robintw's full-sized avatar

Robin Wilson robintw

View GitHub Profile
subroutine abstra (idatm,wl,xmus,xmuv,uw,uo3,uwus,uo3us,
a idatmp,uwpl,uo3pl,uwusp,uo3usp,
a dtwava,dtozon,dtdica,dtoxyg,dtniox,dtmeth,dtmoca,
a utwava,utozon,utdica,utoxyg,utniox,utmeth,utmoca,
a ttwava,ttozon,ttdica,ttoxyg,ttniox,ttmeth,ttmoca )
c transmittance calculation for ozone, water vapor,
c carbon dioxyde and oxygen.
c downward absorption water vapor dtwava
@robintw
robintw / pywatts.py
Last active September 12, 2023 17:29
Code to read data from a CurrentCost EnviR electricity usage meter
import untangle
import serial
def get_data(port='/dev/ttyUSB1', verbose=False):
"""Gets temperature and power usage data from an attached CurrentCost meter.
Parameters:
- port: the port that the CurrentCost meter is attached to. Somthing like /dev/ttyUSB0 or COM1
Returns:
@robintw
robintw / orthoregress.py
Created November 1, 2015 12:01
Orthogonal distance regression in Python, with the same interface as the linregress function
# Copyright (c) 2013, Robin Wilson
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#include<stdio.h>
#include<stdlib.h>
#include<array_alloc.h>
#include<math.h>
#include<mpi.h>
#define NAN (0.0/0.0)
struct global_index
{
@robintw
robintw / gist:3df1464e5c8a7ee8835e
Last active November 12, 2022 01:07
Duplicate slide in python-pptx
def duplicate_slide(pres, index):
source = pres.slides[index]
try:
blank_slide_layout = pres.slide_layouts[6]
except:
blank_slide_layout = pres.slide_layouts[len(pres.slide_layouts) - 1]
dest = pres.slides.add_slide(blank_slide_layout)
for shp in source.shapes:
el = shp.element
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@robintw
robintw / read_aeronet.py
Created July 17, 2016 10:30
Simple function to read AERONET data into a Pandas DataFrame
import pandas as pd
def read_aeronet(filename):
"""Read a given AERONET AOT data file, and return it as a dataframe.
This returns a DataFrame containing the AERONET data, with the index
set to the timestamp of the AERONET observations. Rows or columns
consisting entirely of missing data are removed. All other columns
are left as-is.
"""
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
====
With normal output
====
2021-10-09 21:50:37.540 | DEBUG | prompt_toolkit.key_binding.bindings.focus:focus_next:21 - Set focus to [('[SetMenuPosition]', ''), ('class:dropdown.text', ' Select column ',...
2021-10-09 21:50:38.057 | DEBUG | prompt_toolkit.key_binding.bindings.focus:focus_next:21 - Set focus to [('[SetMenuPosition]', ''), ('class:dropdown.text', ' = ',...
===
With DummyOutput
===
2021-10-09 21:51:12.538 | DEBUG | prompt_toolkit.key_binding.bindings.focus:focus_next:21 - Set focus to [('class:button.arrow', '<', <function Button._get_text_fragments.<locals>.handler at 0x119a321f0>), ('[SetCursorPosition]', ''), ('class:button.text', 'Add filter condition'...
import asyncio
from prompt_toolkit.application import create_app_session
from prompt_toolkit.input.base import DummyInput
from prompt_toolkit.key_binding.key_processor import KeyPress
from prompt_toolkit.keys import Keys
from prompt_toolkit.output import DummyOutput
from pepys_admin.maintenance.dialogs.help_dialog import HelpDialog
from pepys_admin.maintenance.gui import MaintenanceGUI