Open frozznight opened 8 months ago
I have tried a workaround by directly accessing the database. Maybe it seems too intrusive.
import os,glob,uuid,pylpg,sqlite3
import pandas as pd
def main():
pylpgDir = os.path.dirname(pylpg.__file__)
dbFile = glob.glob(os.path.sep.join((pylpgDir,"LPG_*","profilegenerator.db3")))[0]
lpgDB = sqlite3.connect(dbFile)
#Inserting the geographic data, for example Belgium
lpgDB.execute("\
INSERT INTO tblGeographicLocations\
(Name,Guid)\
VALUES\
('(Belgium) Brussels','{}')\
;".format(getUUID()))
#The sqlite database is created using older version, therefore we have to query again to get the location ID
#Otherwise, the sqlite insert command can accept RETURNING clause
brusselID = pd.read_sql_query("\
SELECT ID\
FROM tblGeographicLocations\
WHERE Name LIKE '%%Brussels%%'\
;",lpgDB)["ID"].values[0]
#Example of holidays in Belgium
holidayName = [
"(Belgium) Easter Monday 2024",
"(Belgium) Labour Day 2024",
"(Belgium) Ascension Day 2024",
"(Belgium) Whit Monday 2024",
"(Belgium) Assumption Day 2024",
"(Belgium) All Saints’ Day 2024",
"(Belgium) Armistice Day 2024"
]
holidayDates = [
"1 April 2024 00:00:00",
"1 May 2024 00:00:00",
"9 May 2024 00:00:00",
"20 May 2024 00:00:00",
"15 August 2024 00:00:00",
"1 November 2024 00:00:00",
"11 November 2024 00:00:00"
]
beDF = pd.DataFrame(
data = {
"holidayName" : holidayName,
"holidayDates" : holidayDates
}
)
beDF["holidayDatetime"] = pd.to_datetime(beDF["holidayDates"])
#Inserting holiday dates to the database
for iRow in beDF.index:
holidayName = beDF.iloc[iRow]["holidayName"]
#The description may be rewritten otherwise
holidayDesc = holidayName.replace("(Belgium) ","")
holidayDate = beDF.iloc[iRow]["holidayDatetime"]
guid = getUUID()
lpgDB.execute("\
INSERT INTO tblHolidays\
(Name,Description,Guid)\
VALUES\
('{}','{}','{}')\
;".format(holidayName,holidayDesc,guid))
holidayID = pd.read_sql_query("\
SELECT ID\
FROM tblHolidays\
WHERE Guid = '{}'\
;".format(guid),lpgDB)["ID"].values[0]
guid = getUUID()
lpgDB.execute("\
INSERT INTO tblHolidayDates\
(HolidayID,DateAndTime,Guid)\
VALUES\
({},'{}','{}')\
;".format(holidayID,holidayDate,guid))
#Inserting the holidays to the corresponding geographical entry
guid = getUUID()
lpgDB.execute("\
INSERT INTO tblGeographicLocHolidays\
(HolidayID,GeographicLocationID,Guid)\
VALUES\
({},{},'{}')\
;".format(holidayID,brusselsID,guid))
lpgDB.commit()
return
def getUUID():
res = uuid.uuid4().__str__()
return res
if __name__ == "__main__":
main()
Thanks for posting that. Hope that solves the problem for you. If not, you could also modify the LPG directly. It's fully open source. I don't have the resources right now to significantly extend the API, but would be glad to accept any merge request about that.
Dear @noah80, I have another question. Regarding the solar radiation data, how can I include my local radiation data to the database? I am checking all the tables in the database, I could not find what the corresponding table is.
['sqlite_stat1',
'tblHHTDeviceLocations',
'sqlite_sequence',
'SQLITEADMIN_QUERIES',
'tblHHLocations',
'tblLPGVersion',
'ChargingStationSetEntry',
'tblTransportationChargingStation',
'tblAffTaggingEntries',
'tblAffTagggingSetLoadType',
'tblAffTagReferences',
'tblSettings',
'tblLoadTypes',
'tblHolidays',
'tblHolidayDates',
'tblHolidayProbabilities',
'tblDateBasedProfile',
'tblDateProfilePoints',
'tblVacations',
'tblDesires',
'tblDeviceActionDevices',
'tblDeviceTaggingReferences',
'tblHHTTags',
'tblVacationTimes',
'tblVariables',
'tblTransportationDeviceSets',
'tblTransportationDeviceSetEntries',
'tblTimePoints',
'tblTimeLimits',
'tblTemperatures',
'tblTimeBasedProfile',
'tblTemplateTags',
'tblSubAffordances',
'tblLoadTypeOutcomes',
'tblPersons',
'tblAffordanceDesires',
'tblAffordanceDeviceTimeprofile',
'tblAffordanceOutcomes',
'tblAffordanceStandby',
'tblAffordanceSubaffordance',
'tblAffordanceTag',
'tblAffTaggingSet',
'tblCalculationOutcomes',
'tblGenerators',
'tblGeographicLocHolidays',
'tblDeviceTaggingEntries',
'tblTemperatureProfiles',
'tblAffordanceVariableOps',
'tblAffordanceVariableReqs',
'tblCHHTraits',
'tblDeviceActionGroups',
'tblDeviceCategories',
'tblChargingStationSets',
'tblDeviceActions',
'tblDeviceTags',
'tblEnergyStorageSignals',
'tblHousehold',
'tblHouseholdPlanEntries',
'tblDeviceSelectionDeviceActions',
'tblDeviceSelectionItems',
'tblDeviceTaggingSetLoadType',
'tblDeviceTaggingSets',
'tblEnergyStorages',
'tblDeviceSelections',
'tblHHAffordances',
'tblHHAutonomousDevices',
'tblHHTTraits',
'tblHouses',
'tblLocations',
'tblModularHouseholds',
'tblTraitTags',
'tblRealDeviceLoadType',
'tblLocationDevices',
'tblTimeLimitEntries',
'tblHHDeviceLocations',
'tblHHPersons',
'tblHHVacations',
'tblHouseTypes',
'tblHouseTypeTransformationDevice',
'tblHouseTypeGenerators',
'tblHouseTypeDevices',
'tblModularHouseholdTags',
'tblSTHouseSizes',
'tblSTHouseholdDistributions',
'tblSTHouseholdTemplates',
'tblSettlementHH',
'tblTemplatePerson',
'tblSubAffordanceDesires',
'tblSubAffordanceVariableOps',
'tblHouseholdTraits',
'tblHHTLocations',
'tblHouseholdTemplates',
'tblTemplatePersonTrait',
'tblHouseholdPlans',
'tblHouseTypeEnergyStorages',
'tblTransportationDeviceCategories',
'tblSiteLocations',
'tblTransportationDevices',
'tblTransportationDeviceLoads',
'tblTransformationDevices',
'tblTransformationDeviceLoadType',
'tblTransformationDeviceConditions',
'tblTransformationFactor',
'tblHHTAutonomousDevices',
'tblHHTDesires',
'tblHHTAffordances',
'tblHHGEntryPerson',
'tblHHTemplateTag',
'tblSettlementTemplates',
'tblSTHouseholdDistributionTags',
'tblSTHouseTypes',
'tblSTTraitLimits',
'tblOptions',
'tblHouseHouseholds',
'tblSettlement',
'tblTravelRoutes',
'tblTravelRouteSteps',
'tblChargingStationSetEntries',
'tblHHTemplateVacations',
'tblAffordances',
'tblSTChargingStationSets',
'tblSTTravelRouteSets',
'tblSTTransportationDeviceSets',
'tblLivingPatternTags',
'tblHHTLivingPatternTags',
'tblCHHPersons',
'tblHHTemplatePerson',
'tblHHGEntry',
'tblDevices',
'tblTravelRouteSet',
'tblSites',
'tblTravelRouteSetEntry',
'tblGeographicLocations']
Not sure what you want to do with other radiation data. That is only used in the LPG to determine, when the people turn on the lights at home. So the influence of that is rather small. If you want to properly model things like solar gains in the building, then I would like to recommend our complementary building simulator HiSim.
But if you really insist, it should be in the table tblDateBasedProfile and tblDateProfilePoints.
Thank you @noah80 for your reply, I will look at the other tool. From my side, there is no more discussion to follow up. We can close this issue.
I am using this tool to generate consumption profile (e.g. water, electricity) as input for my building energy model using EnergyPlus. I am working in the LINUX environment. I am trying to modify the day schedules, especially the holidays, according to my local holidays. As far as I looked at the python bindings (API), I could not find how to realized the modifications. Are there any examples modifying the geographical contents using python API? Thanks.