S5.Tecplot.SSWeather#

class S5.Tecplot.SSWeather(filename=None)[source]#

Bases: TecplotData

Represents a SolarSim Weather file.

__init__(filename=None)#

Methods

__init__([filename])

add_day_time_cols()

Create the 'Day' and 'Time' columns.

add_timestamp(startday[, day, time])

Add a DateTime column so each row have a timestamp.

check_rectangular()

Check if the weather file is a fully rectangular grid in space and time.

check_zone()

Check the zone detail matches the DataFrame.

readfile(filename)

Read the file and load populate self.data with the contents.

update_zone_1d()

Update the zone detail assuming a 1d data structure.

write_tecplot(filename[, datum])

Write the TecplotData to a .dat file.

add_day_time_cols()[source]#

Create the ‘Day’ and ‘Time’ columns.

Create the ‘Day’ and ‘Time’ columns in weather file when the dataframe is indexed by datetime.

Raises:

TypeError when the index is not a DatetimeIndex.

add_timestamp(startday: str, day: str = 'Day', time: str = 'Time (HHMM)') None[source]#

Add a DateTime column so each row have a timestamp.

Use the ‘Day’ and ‘Time (HHMM)’ columns to create a ‘DateTime’ column.

Parameters:
  • startday – First day of the race in the format ‘DDMMYYYY’.

  • day – Column name for the day column, default ‘Day’.

  • time – Column name for the time column, default ‘Time (HHMM)’.

Returns:

None, modifies self.data and adds a new column named ‘DateTime’.

Examples

>>> weather_file = SSWeather("Weather-2019.dat")
>>> weather_file.add_timestamp(startday='13102019')
>>> weather_file.add_timestamp(startday='13102019', day = 'Day', time = 'Time (HHMM)')
check_rectangular()[source]#

Check if the weather file is a fully rectangular grid in space and time.

Sometimes measurements are taken at slightly different time at each station. For example: 3 minute past the hour at Darwin but 6 minute past the hour at Coober Pedy. The means that although there may be the same amount of points at both location, there are double the amount of unique DateTime in the file, messing up the j index value in the zone data.

check_zone() bool#

Check the zone detail matches the DataFrame.

This is not an exhaustive check, but just a check to make sure that the number of rows matchs the produce of I*J*K in the Zone line.

Returns:

True if the zone detail matches the total rows

Examples

>>> velocity = TecplotData("Velocity.dat")
>>> if not velocity.check_zone():
>>>     print("Zone detail mismatch!!")
readfile(filename: str | PathLike) None#

Read the file and load populate self.data with the contents. :param filename: Path to datafile in Tecplot format.

Returns:

None, data from the file is loaded into the instance as the self.data attribute

Examples

>>> data = TecplotData()
>>> data.readfile("Velocity.dat")
update_zone_1d()#

Update the zone detail assuming a 1d data structure.

Update the zone detail such that i = the size of the dataframe in self.data.

Examples

>>> velocity = TecplotData("Velocity.dat")
>>> velocity.update_zone_1d()
write_tecplot(filename, datum=False) None#

Write the TecplotData to a .dat file.

Parameters:
  • filename – Filename including extension (.dat)

  • datum – If DSW datum lines are written, default false

Returns:

None

Examples

>>> velocity = TecplotData("Velocity.dat")
>>> velocity.write_tecplot("Velocity.dat")