Search is not available for this dataset
text stringlengths 75 104k |
|---|
def latitude(self, value):
"""Set latitude value."""
self._latitude = math.radians(float(value))
assert -self.PI / 2 <= self._latitude <= self.PI / 2, \
"latitude value should be between -90..90." |
def longitude(self, value):
"""Set longitude value in degrees."""
self._longitude = math.radians(float(value))
# update time_zone
if abs((value / 15.0) - self.time_zone) > 1:
# if time_zone doesn't match the longitude update the time_zone
self.time_zone = value /... |
def is_daylight_saving_hour(self, datetime):
"""Check if a datetime is a daylight saving time."""
if not self.daylight_saving_period:
return False
return self.daylight_saving_period.isTimeIncluded(datetime.hoy) |
def calculate_sun(self, month, day, hour, is_solar_time=False):
"""Get Sun data for an hour of the year.
Args:
month: An integer between 1-12
day: An integer between 1-31
hour: A positive number between 0..23
is_solar_time: A boolean to indicate if the in... |
def calculate_sun_from_hoy(self, hoy, is_solar_time=False):
"""Get Sun data for an hour of the year.
Args:
datetime: Ladybug datetime
is_solar_time: A boolean to indicate if the input hour is solar time
(Default: False).
Returns:
A sun object... |
def calculate_sun_from_date_time(self, datetime, is_solar_time=False):
"""Get Sun for an hour of the year.
This code is originally written by Trygve Wastvedt \
(Trygve.Wastvedt@gmail.com)
based on (NOAA) and modified by Chris Mackey and Mostapha Roudsari
Args:
date... |
def calculate_sunrise_sunset(self, month, day, depression=0.833,
is_solar_time=False):
"""Calculate sunrise, noon and sunset.
Return:
A dictionary. Keys are ("sunrise", "noon", "sunset")
"""
datetime = DateTime(month, day, hour=12, leap_year=... |
def calculate_sunrise_sunset_from_datetime(self, datetime, depression=0.833,
is_solar_time=False):
"""Calculate sunrise, sunset and noon for a day of year."""
# TODO(mostapha): This should be more generic and based on a method
if datetime.year != 20... |
def _calculate_solar_geometry(self, datetime):
"""Calculate Solar geometry for an hour of the year.
Attributes:
datetime: A Ladybug datetime
Returns:
Solar declination: Solar declination in radians
eq_of_time: Equation of time as minutes
"""
... |
def _calculate_sunrise_hour_angle(self, solar_dec, depression=0.833):
"""Calculate hour angle for sunrise time in degrees."""
hour_angle_arg = math.degrees(math.acos(
math.cos(math.radians(90 + depression)) /
(math.cos(math.radians(self.latitude)) * math.cos(
mat... |
def _calculate_solar_time(self, hour, eq_of_time, is_solar_time):
"""Calculate Solar time for an hour."""
if is_solar_time:
return hour
return (
(hour * 60 + eq_of_time + 4 * math.degrees(self._longitude) -
60 * self.time_zone) % 1440) / 60 |
def _calculate_solar_time_by_doy(self, hour, doy):
"""This is how radiance calculates solar time.
This is a place holder and \
need to be validated against calculateSolarTime.
"""
raise NotImplementedError()
return (0.170 * math.sin((4 * math.pi / 373) * (doy - 80)) -
... |
def draw_sunpath(self,
hoys=None,
origin=None,
scale=1, sun_scale=1, annual=True, rem_night=True):
"""Create sunpath geometry. \
This method should only be used from the + libraries.
Args:
hoys: An optional list of hours... |
def _analemma_position(self, hour):
"""Check what the analemma position is for an hour.
This is useful for calculating hours of analemma curves.
Returns:
-1 if always night,
0 if both day and night,
1 if always day.
"""
# check for 21 dec and... |
def _analemma_suns(self):
"""Calculate times that should be used for drawing analemma_curves.
Returns:
A list of list of analemma suns.
"""
for h in xrange(0, 24):
if self._analemma_position(h) < 0:
continue
elif self._analemma_positio... |
def _daily_suns(self, datetimes):
"""Get sun curve for multiple days of the year."""
for dt in datetimes:
# calculate sunrise sunset and noon
nss = self.calculate_sunrise_sunset(dt.month, dt.day)
dts = tuple(nss[k] for k in ('sunrise', 'noon', 'sunset'))
i... |
def _calculate_sun_vector(self):
"""Calculate sun vector for this sun."""
z_axis = Vector3(0., 0., -1.)
x_axis = Vector3(1., 0., 0.)
north_vector = Vector3(0., 1., 0.)
# rotate north vector based on azimuth, altitude, and north
_sun_vector = north_vector \
.r... |
def saturated_vapor_pressure(t_kelvin):
"""Saturated Vapor Pressure (Pa) at t_kelvin (K).
This function accounts for the different behaviour above vs. below
the freezing point of water.
Note:
[1] W. Wagner and A. Pru:" The IAPWS Formulation 1995 for the Thermodynamic
Properties of Ordi... |
def humid_ratio_from_db_rh(db_temp, rel_humid, b_press=101325):
"""Humidity Ratio (kg water/kg air) at a db_temp (C),
rel_humid (%) and Pressure b_press (Pa).
Note:
[1] Vaisala. (2013) Humidity Conversion Formulas:
Calculation Formulas for Humidity.
www.vaisala.com/Vaisala%20Documen... |
def wet_bulb_from_db_rh(db_temp, rh, b_press=101325):
"""Wet Bulb Temperature (C) at db_temp (C),
Relative Humidity rh (%), and Pressure b_press (Pa).
Note:
[1] J. Sullivan and L. D. Sanders. "Method for obtaining wet-bulb temperatures by
modifying the psychrometric formula." Center for Exp... |
def dew_point_from_db_rh(db_temp, rh):
"""Dew Point Temperature (C) at Dry Bulb Temperature db_temp (C) and
Relative Humidity rh (%).
Note:
[1] J. Sullivan and L. D. Sanders. "Method for obtaining wet-bulb temperatures by
modifying the psychrometric formula." Center for Experiment Design an... |
def rel_humid_from_db_hr(db_temp, humid_ratio, b_press=101325):
"""Relative Humidity (%) at humid_ratio (kg water/kg air), db_temp (C),
and Pressure b_press (Pa).
"""
pw = (humid_ratio * 1000 * b_press) / (621.9907 + (humid_ratio * 1000))
pws = saturated_vapor_pressure(db_temp + 273.15)
rel_humi... |
def rel_humid_from_db_enth(db_temp, enthalpy, b_press=101325):
"""Relative Humidity (%) at db_temp (C), enthalpy (kJ/kg)
and Pressure b_press (Pa).
"""
assert enthalpy >= 0, 'enthalpy must be' \
'greater than 0. Got {}'.format(str(enthalpy))
hr = (enthalpy - (1.006 * db_temp)) / ((1.84 * db_... |
def rel_humid_from_db_dpt(db_temp, dew_pt):
"""Relative Humidity (%) at db_temp (C), and dew_pt (C).
"""
pws_ta = saturated_vapor_pressure(db_temp + 273.15)
pws_td = saturated_vapor_pressure(dew_pt + 273.15)
rh = 100 * (pws_td / pws_ta)
return rh |
def rel_humid_from_db_wb(db_temp, wet_bulb, b_press=101325):
"""Relative Humidity (%) at db_temp(C), wet_bulb (C), and Pressure b_press (Pa).
"""
# Calculate saturation pressure.
p_ws = saturated_vapor_pressure(db_temp + 273.15)
p_ws_wb = saturated_vapor_pressure(wet_bulb + 273.15)
# calculate p... |
def dew_point_from_db_hr(db_temp, hr, b_press=101325):
"""Dew Point Temperature (C) at Temperature db_temp (C),
Humidity Ratio hr (kg water/kg air) and Pressure b_press (Pa).
"""
rh = rel_humid_from_db_hr(db_temp, hr, b_press)
td = dew_point_from_db_rh(db_temp, rh)
return td |
def dew_point_from_db_enth(db_temp, enthlpy, b_press=101325):
"""Dew Point Temperature (C) at Temperature db_temp (C), enthalpy (kJ/kg)
and Pressure b_press (Pa).
"""
rh = rel_humid_from_db_enth(db_temp, enthlpy, b_press)
td = dew_point_from_db_rh(db_temp, rh)
return td |
def dew_point_from_db_wb(db_temp, wet_bulb, b_press=101325):
"""Dew Point Temperature (C) at Temperature db_temp (C), wet_bulb (C)
and Pressure b_press (Pa).
"""
rh = rel_humid_from_db_wb(db_temp, wet_bulb, b_press)
td = dew_point_from_db_rh(db_temp, rh)
return td |
def db_temp_from_wb_rh(wet_bulb, rel_humid, b_press=101325):
"""Dry Bulb Temperature (C) and humidity_ratio at at wet_bulb (C),
rel_humid (%) and Pressure b_press (Pa).
Formula is only valid for rel_humid == 0 or rel_humid == 100.
"""
assert rel_humid == 0 or rel_humid == 100, 'formula is only vali... |
def from_json(cls, data):
"""Create a DDY from a dictionary.
Args:
data = {
"location": ladybug Location schema,
"design_days": [] // list of ladybug DesignDay schemas}
"""
required_keys = ('location', 'design_days')
for key in required_keys:
... |
def from_ddy_file(cls, file_path):
"""Initalize from a ddy file object from an existing ddy file.
args:
file_path: A string representing a complete path to the .ddy file.
"""
# check that the file is there
if not os.path.isfile(file_path):
raise ValueErro... |
def save(self, file_path):
"""Save ddy object as a .ddy file.
args:
file_path: A string representing the path to write the ddy file to.
"""
# write all data into the file
# write the file
data = self.location.ep_style_location_string + '\n\n'
for d_da... |
def filter_by_keyword(self, keyword):
"""Return a list of ddys that have a certain keyword in their name.
This is useful for selecting out design days from a ddy file that are
for a specific type of condition (for example, .4% cooling design days)
"""
filtered_days = []
... |
def to_json(self):
"""Convert the Design Day to a dictionary."""
return {
'location': self.location.to_json(),
'design_days': [des_d.to_json() for des_d in self.design_days]
} |
def from_json(cls, data):
"""Create a Design Day from a dictionary.
Args:
data = {
"name": string,
"day_type": string,
"location": ladybug Location schema,
"dry_bulb_condition": ladybug DryBulbCondition schema,
"humidity_condition"... |
def from_ep_string(cls, ep_string, location):
"""Initalize from an EnergyPlus string of a SizingPeriod:DesignDay.
args:
ep_string: A full string representing a SizingPeriod:DesignDay.
"""
# format the object into a list of properties
ep_string = ep_string.strip()
... |
def from_design_day_properties(cls, name, day_type, location, analysis_period,
dry_bulb_max, dry_bulb_range, humidity_type,
humidity_value, barometric_p, wind_speed, wind_dir,
sky_model, sky_properties):
"""... |
def from_ashrae_dict_heating(cls, ashrae_dict, location,
use_990=False, pressure=None):
"""Create a heating design day object from a ASHRAE HOF dictionary.
Args:
ashrae_dict: A dictionary with 15 keys that match those in the
heating_keys prop... |
def from_ashrae_dict_cooling(cls, ashrae_dict, location,
use_010=False, pressure=None, tau=None):
"""Create a heating design day object from a ASHRAE HOF dictionary.
Args:
ashrae_dict: A dictionary with 32 keys that match those in the
cooling... |
def ep_style_string(self):
"""Serialize object to an EnerygPlus SizingPeriod:DesignDay.
Returns:
ep_string: A full string representing a SizingPeriod:DesignDay.
"""
# Put together the values in the order that they exist in the ddy file
ep_vals = [self.name,
... |
def analysis_period(self):
"""The analysisperiod of the design day."""
return AnalysisPeriod(
self.sky_condition.month,
self.sky_condition.day_of_month,
0,
self.sky_condition.month,
self.sky_condition.day_of_month,
23) |
def hourly_dew_point(self):
"""A data collection containing hourly dew points over they day."""
dpt_data = self._humidity_condition.hourly_dew_point_values(
self._dry_bulb_condition)
return self._get_daily_data_collections(
temperature.DewPointTemperature(), 'C', dpt_data... |
def hourly_relative_humidity(self):
"""A data collection containing hourly relative humidity over they day."""
dpt_data = self._humidity_condition.hourly_dew_point_values(
self._dry_bulb_condition)
rh_data = [rel_humid_from_db_dpt(x, y) for x, y in zip(
self._dry_bulb_con... |
def hourly_solar_radiation(self):
"""Three data collections containing hourly direct normal, diffuse horizontal,
and global horizontal radiation.
"""
dir_norm, diff_horiz, glob_horiz = \
self._sky_condition.radiation_values(self._location)
dir_norm_data = self._get_d... |
def hourly_horizontal_infrared(self):
"""A data collection containing hourly horizontal infrared intensity in W/m2.
"""
sky_cover = self._sky_condition.hourly_sky_cover
db_temp = self._dry_bulb_condition.hourly_values
dp_temp = self._humidity_condition.hourly_dew_point_values(
... |
def _get_daily_data_collections(self, data_type, unit, values):
"""Return an empty data collection."""
data_header = Header(data_type=data_type, unit=unit,
analysis_period=self.analysis_period,
metadata={'source': self._location.source,
... |
def to_json(self):
"""Convert the Design Day to a dictionary."""
return {
'name': self.name,
'day_type': self.day_type,
'location': self.location.to_json(),
'dry_bulb_condition': self.dry_bulb_condition.to_json(),
'humidity_condition': self.hum... |
def hourly_values(self):
"""A list of temperature values for each hour over the design day."""
return [self._dry_bulb_max - self._dry_bulb_range * x for
x in self.temp_multipliers] |
def to_json(self):
"""Convert the Dry Bulb Condition to a dictionary."""
return {
'dry_bulb_max': self.dry_bulb_max,
'dry_bulb_range': self.dry_bulb_range,
'modifier_type': self.modifier_type,
'modifier_schedule': self.modifier_schedule
} |
def from_json(cls, data):
"""Create a Humidity Condition from a dictionary.
Args:
data = {
"hum_type": string,
"hum_value": float,
"barometric_pressure": float,
"schedule": string,
"wet_bulb_range": string}
"""
# Ch... |
def hourly_dew_point_values(self, dry_bulb_condition):
"""Get a list of dew points (C) at each hour over the design day.
args:
dry_bulb_condition: The dry bulb condition for the day.
"""
hourly_dew_point = []
max_dpt = self.dew_point(dry_bulb_condition.dry_bulb_max)
... |
def dew_point(self, db):
"""Get the dew point (C), which is constant throughout the day (except at saturation).
args:
db: The maximum dry bulb temperature over the day.
"""
if self._hum_type == 'Dewpoint':
return self._hum_value
elif self._hum_type == 'We... |
def to_json(self):
"""Convert the Humidity Condition to a dictionary."""
return {
'hum_type': self.hum_type,
'hum_value': self.hum_value,
'barometric_pressure': self.barometric_pressure,
'schedule': self.schedule,
'wet_bulb_range': self.wet_bul... |
def from_json(cls, data):
"""Create a Wind Condition from a dictionary.
Args:
data = {
"wind_speed": float,
"wind_direction": float,
"rain": bool,
"snow_on_ground": bool}
"""
# Check required and optional keys
optional_... |
def to_json(self):
"""Convert the Wind Condition to a dictionary."""
return {
'wind_speed': self.wind_speed,
'wind_direction': self.wind_direction,
'rain': self.rain,
'snow_on_ground': self.snow_on_ground
} |
def from_json(cls, data):
"""Create a Sky Condition from a dictionary.
Args:
data = {
"solar_model": string,
"month": int,
"day_of_month": int,
"daylight_savings_indicator": string // "Yes" or "No"}
"""
# Check required and opt... |
def _get_datetimes(self, timestep=1):
"""List of datetimes based on design day date and timestep."""
start_moy = DateTime(self._month, self._day_of_month).moy
if timestep == 1:
start_moy = start_moy + 30
num_moys = 24 * timestep
return tuple(
DateTime.from... |
def to_json(self):
"""Convert the Sky Condition to a dictionary."""
return {
'solar_model': self.solar_model,
'month': self.month,
'day_of_month': self.day_of_month,
'daylight_savings_indicator': self.daylight_savings_indicator,
'beam_shced': s... |
def from_analysis_period(cls, analysis_period, clearness=1,
daylight_savings_indicator='No'):
""""Initialize a OriginalClearSkyCondition from an analysis_period"""
_check_analysis_period(analysis_period)
return cls(analysis_period.st_month, analysis_period.st_day, cl... |
def from_json(cls, data):
"""Create a Sky Condition from a dictionary.
Args:
data = {
"solar_model": string,
"month": int,
"day_of_month": int,
"clearness": float,
"daylight_savings_indicator": string // "Yes" or "No"}
"""
... |
def radiation_values(self, location, timestep=1):
"""Lists of driect normal, diffuse horiz, and global horiz rad at each timestep.
"""
# create sunpath and get altitude at every timestep of the design day
sp = Sunpath.from_location(location)
altitudes = []
dates = self._g... |
def to_json(self):
"""Convert the Sky Condition to a dictionary."""
return {
'solar_model': self.solar_model,
'month': self.month,
'day_of_month': self.day_of_month,
'clearness': self.clearness,
'daylight_savings_indicator': self.daylight_savin... |
def from_analysis_period(cls, analysis_period, tau_b, tau_d,
daylight_savings_indicator='No'):
""""Initialize a RevisedClearSkyCondition from an analysis_period"""
_check_analysis_period(analysis_period)
return cls(analysis_period.st_month, analysis_period.st_day, ta... |
def to_json(self):
"""Convert the Sky Condition to a dictionary."""
return {
'solar_model': self.solar_model,
'month': self.month,
'day_of_month': self.day_of_month,
'tau_b': self.tau_b,
'tau_d': self.tau_d,
'daylight_savings_indica... |
def from_json(cls, data):
"""Create a Data Collection from a dictionary.
Args:
{
"header": A Ladybug Header,
"values": An array of values,
"datetimes": An array of datetimes,
"validated_a_period": Boolean for whether header ana... |
def convert_to_unit(self, unit):
"""Convert the Data Collection to the input unit."""
self._values = self._header.data_type.to_unit(
self._values, unit, self._header.unit)
self._header._unit = unit |
def convert_to_ip(self):
"""Convert the Data Collection to IP units."""
self._values, self._header._unit = self._header.data_type.to_ip(
self._values, self._header.unit) |
def convert_to_si(self):
"""Convert the Data Collection to SI units."""
self._values, self._header._unit = self._header.data_type.to_si(
self._values, self._header.unit) |
def to_unit(self, unit):
"""Return a Data Collection in the input unit."""
new_data_c = self.duplicate()
new_data_c.convert_to_unit(unit)
return new_data_c |
def is_in_data_type_range(self, raise_exception=True):
"""Check if collection values are in physically possible ranges for the data_type.
If this method returns False, the Data Collection's data is
physically or mathematically impossible for the data_type."""
return self._header.data_ty... |
def get_highest_values(self, count):
"""Get a list of the the x highest values of the Data Collection and their indices.
This is useful for situations where one needs to know the times of
the year when the largest values of a data collection occur. For example,
there is a European dayi... |
def get_lowest_values(self, count):
"""Get a list of the the x lowest values of the Data Collection and their indices.
This is useful for situations where one needs to know the times of
the year when the smallest values of a data collection occur.
Args:
count: Integer repre... |
def get_percentile(self, percentile):
"""Get a value representing a the input percentile of the Data Collection.
Args:
percentile: A float value from 0 to 100 representing the
requested percentile.
Return:
The Data Collection value at the input percentil... |
def filter_by_conditional_statement(self, statement):
"""Filter the Data Collection based on a conditional statement.
Args:
statement: A conditional statement as a string (e.g. a > 25 and a%5 == 0).
The variable should always be named as 'a' (without quotations).
Re... |
def filter_by_pattern(self, pattern):
"""Filter the Data Collection based on a list of booleans.
Args:
pattern: A list of True/False values. Typically, this is a list
with a length matching the length of the Data Collections values
but it can also be a patte... |
def is_collection_aligned(self, data_collection):
"""Check if this Data Collection is aligned with another.
Aligned Data Collections are of the same Data Collection class, have the
same number of values and have matching datetimes.
Args:
data_collection: The Data Collection... |
def get_aligned_collection(self, value=0, data_type=None, unit=None, mutable=None):
"""Return a Collection aligned with this one composed of one repeated value.
Aligned Data Collections are of the same Data Collection class, have the same
number of values and have matching datetimes.
A... |
def duplicate(self):
"""Return a copy of the current Data Collection."""
collection = self.__class__(self.header.duplicate(), self.values, self.datetimes)
collection._validated_a_period = self._validated_a_period
return collection |
def to_json(self):
"""Convert Data Collection to a dictionary."""
return {
'header': self.header.to_json(),
'values': self._values,
'datetimes': self.datetimes,
'validated_a_period': self._validated_a_period
} |
def filter_collections_by_statement(data_collections, statement):
"""Generate a filtered data collections according to a conditional statement.
Args:
data_collections: A list of aligned Data Collections to be evaluated
against the statement.
statement: A conditio... |
def pattern_from_collections_and_statement(data_collections, statement):
"""Generate a list of booleans from data collections and a conditional statement.
Args:
data_collections: A list of aligned Data Collections to be evaluated
against the statement.
statement:... |
def are_collections_aligned(data_collections, raise_exception=True):
"""Test if a series of Data Collections are aligned with one another.
Aligned Data Collections are of the same Data Collection class, have the
same number of values and have matching datetimes.
Args:
data_... |
def compute_function_aligned(funct, data_collections, data_type, unit):
"""Compute a function with a list of aligned data collections or individual values.
Args:
funct: A function with a single numerical value as output and one or
more numerical values as input.
... |
def _check_conditional_statement(statement, num_collections):
"""Method to check conditional statements to be sure that they are valid.
Args:
statement: A conditional statement as a string (e.g. a>25 and a%5==0).
The variable should always be named as 'a' (without quotations... |
def _filter_by_statement(self, statement):
"""Filter the data collection based on a conditional statement."""
self.__class__._check_conditional_statement(statement, 1)
_filt_values, _filt_datetimes = [], []
for i, a in enumerate(self._values):
if eval(statement, {'a': a}):
... |
def _filter_by_pattern(self, pattern):
"""Filter the Filter the Data Collection based on a list of booleans."""
try:
_len = len(pattern)
except TypeError:
raise TypeError("pattern is not a list of Booleans. Got {}".format(
type(pattern)))
_filt_val... |
def _check_values(self, values):
"""Check values whenever they come through the values setter."""
assert isinstance(values, Iterable) and not \
isinstance(values, (str, dict, bytes, bytearray)), \
'values should be a list or tuple. Got {}'.format(type(values))
assert len(... |
def _check_aligned_header(self, data_type, unit):
"""Check the header inputs whenever get_aligned_collection is called."""
if data_type is not None:
assert isinstance(data_type, DataTypeBase), \
'data_type must be a Ladybug DataType. Got {}'.format(type(data_type))
... |
def _check_aligned_value(self, value):
"""Check the value input whenever get_aligned_collection is called."""
if isinstance(value, Iterable) and not isinstance(
value, (str, dict, bytes, bytearray)):
assert len(value) == len(self._values), "Length of value ({}) must match "\
... |
def _percentile(self, values, percent, key=lambda x: x):
"""Find the percentile of a list of values.
Args:
values: A list of values for which percentiles are desired
percent: A float value from 0 to 100 representing the requested percentile.
key: optional key functio... |
def to_ip(self, values, from_unit):
"""Return values in IP and the units to which the values have been converted."""
if from_unit in self.ip_units:
return values, from_unit
elif from_unit == 'tonne':
return self.to_unit(values, 'ton', from_unit), 'ton'
else:
... |
def to_si(self, values, from_unit):
"""Return values in SI and the units to which the values have been converted."""
if from_unit in self.si_units:
return values, from_unit
elif from_unit == 'ton':
return self.to_unit(values, 'tonne', from_unit), 'tonne'
else:
... |
def from_json(cls, data):
"""Creat datetime from a dictionary.
Args:
data: {
'month': A value for month between 1-12. (Defualt: 1)
'day': A value for day between 1-31. (Defualt: 1)
'hour': A value for hour between 0-23. (Defualt: 0)
... |
def from_hoy(cls, hoy, leap_year=False):
"""Create Ladybug Datetime from an hour of the year.
Args:
hoy: A float value 0 <= and < 8760
"""
return cls.from_moy(round(hoy * 60), leap_year) |
def from_moy(cls, moy, leap_year=False):
"""Create Ladybug Datetime from a minute of the year.
Args:
moy: An integer value 0 <= and < 525600
"""
if not leap_year:
num_of_minutes_until_month = (0, 44640, 84960, 129600, 172800, 217440,
... |
def from_date_time_string(cls, datetime_string, leap_year=False):
"""Create Ladybug DateTime from a DateTime string.
Usage:
dt = DateTime.from_date_time_string("31 Dec 12:00")
"""
dt = datetime.strptime(datetime_string, '%d %b %H:%M')
return cls(dt.month, dt.day, dt... |
def _calculate_hour_and_minute(float_hour):
"""Calculate hour and minutes as integers from a float hour."""
hour, minute = int(float_hour), int(round((float_hour - int(float_hour)) * 60))
if minute == 60:
return hour + 1, 0
else:
return hour, minute |
def add_minute(self, minute):
"""Create a new DateTime after the minutes are added.
Args:
minute: An integer value for minutes.
"""
_moy = self.moy + int(minute)
return self.__class__.from_moy(_moy) |
def to_json(self):
"""Get date time as a dictionary."""
return {'year': self.year,
'month': self.month,
'day': self.day,
'hour': self.hour,
'minute': self.minute} |
def add_scalebar(ax, matchx=True, matchy=True, hidex=True, hidey=True, unitsx='', unitsy='', scalex=1, scaley=1, **kwargs):
""" Add scalebars to axes
Adds a set of scale bars to *ax*, matching the size to the ticks of the plot
and optionally hiding the x and y axes
- ax : the axis to attach ticks to
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.