Curve Fitting to a time series in the format ‘datetime’?

Instead of plotting datenums, use the associated datetimes. import numpy as np import matplotlib.pyplot as plt import matplotlib.dates as mdates import datetime as DT import time dates = [DT.datetime(1978, 7, 7), DT.datetime(1980, 9, 26), DT.datetime(1983, 8, 1), DT.datetime(1985, 8, 8)] y = [0.00134328779552718, 0.00155187668863844, 0.0039431374327427, 0.00780037563783297] yerr = [0.0000137547160254577, 0.0000225670232594083, 0.000105623642510075, 0.00011343121508] x = mdates.date2num(dates) … Read more

In PHP given a month string such as “November” how can I return 11 without using a 12 part switch statement?

Try echo date(‘n’, strtotime(‘November’)); // returns 11 If you have to do this often, you might consider using an array that has these values hardcoded: $months = array( 1 => ‘January’, 2 => ‘February’, 3 => ‘March’, 4 => ‘April’, 5 => ‘May’, 6 => ‘June’, 7 => ‘July’, 8 => ‘August’, 9 => ‘September’, … Read more

Get week number (in the year) from a date PHP

Today, using PHP’s DateTime objects is better: <?php $ddate = “2012-10-18”; $date = new DateTime($ddate); $week = $date->format(“W”); echo “Weeknummer: $week”; It’s because in mktime(), it goes like this: mktime(hour, minute, second, month, day, year); Hence, your order is wrong. <?php $ddate = “2012-10-18”; $duedt = explode(“-“, $ddate); $date = mktime(0, 0, 0, $duedt[1], $duedt[2], … Read more