-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify geographic content using python API in LINUX #12
Comments
I have tried a workaround by directly accessing the database. 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, ['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 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.
The text was updated successfully, but these errors were encountered: