Skip to content

Instantly share code, notes, and snippets.

View prateekiiest's full-sized avatar
🎓
I may be slow to respond.

Prateek Chanda prateekiiest

🎓
I may be slow to respond.
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@prateekiiest
prateekiiest / 0_reuse_code.js
Created July 25, 2017 07:59
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@prateekiiest
prateekiiest / parse_time_return.md
Last active March 25, 2018 13:42
This table shows the modifications that needs to be done in parse_time to return Time objects instead of Datetime objects

First importing import astropy.time as t

Input instances for time_string Current working of parse_time Proposed changes to return astropy.Time
astropy.Time return time_string.datetime return time_string
now return datetime.utcnow() return t.Time.now()
pandas.Timeseries return time_string.to_pydatetime() return t.Time(time_string)
isinstance(time_string, pandas.Series) and 'datetime64' in str(time_string.dtype) return np.array([dt.to_pydatetime() for dt in time_string]) return np.array([t.Time(dt) for dt in time_string])
datetime return time_string return t.Time(time_string)
tuple return datetime(*time_string) if time = (2018,10,3,10,43,5,6) see code here
@prateekiiest
prateekiiest / OCCULT-2_Implementation.md
Last active March 21, 2019 13:10
A rough pseudo-code work-out of OCCULT-2 Algorithm

Background Suppression

def backgd_sup(image_data,  zmin, qmed =None):
  
  """
  Parameters:
  
@prateekiiest
prateekiiest / DateInput.py
Created March 25, 2018 05:10
Enhancement for Handling Date inputs
def parse_time(time_string, time_format='', **kwargs):
if isinstance(time_string, date):
dat = (''.join("{}-" for i in range(len(time_string.timetuple()[0:3])))).rstrip('-')
return T.Time(dat.format(*time_string.timetuple()[0:3]) + " " + datetime.time().isoformat())
@prateekiiest
prateekiiest / TimeDelta.py
Created March 25, 2018 05:18
TimeDelta Enhancement
import astropy.Time as T
def parse_time(time_string, time_format='', **kwargs):
if time_format == 'utime' or isinstance(time_string, (int, float)):
return T.Time(T.Time('1979-01-01')) + T.TimeDelta(time_string, format = 'sec')
@prateekiiest
prateekiiest / _parse_dt64.py
Created March 25, 2018 05:20
Enhancement for _parse_dt64
import astropy.Time as T
def _parse_dt64(dt):
"""
Parse a single numpy datetime64 object
"""
# Validate (in an agnostic way) that we are getting a datetime rather than a date
s= ((dt.astype(T.Time).timetuple()[:6]))
return T.Time('{}-{}-{}'.format(*s))
@prateekiiest
prateekiiest / tuple.py
Last active March 26, 2018 02:56
Enhancement for Handling Tuple
def parse_time(time, time_format='', **kwargs):
# for example time = (2018,10,3,10,43,5,6)
if isinstance(time_string, tuple):
dat = (''.join("{}-" for i in range(len(time[0:3])))).rstrip('-')
tim = (''.join("{}:" for i in range(len(time[3:6])))).rstrip(':')
mill_sec = (''.join(".{}" for i in range(len(time[6:])))).rstrip(':')
return T.Time((dat + " " + tim + mill_sec).format(*time))