-
Notifications
You must be signed in to change notification settings - Fork 20
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
Metadata #153
Open
bam241
wants to merge
13
commits into
cyclus:main
Choose a base branch
from
bam241:metadata
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Metadata #153
Changes from 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0da27e2
adding Metadat in RootMetric
bam241 15a9aa0
start usage Metric implementation
bam241 fe9e984
some progress on metadata
bam241 d7f4fe3
udpate
bam241 95fbd75
decom to timestep working
bam241 fc2f0b1
working timeseries
bam241 15735f2
celaring trailing space
bam241 8d5f7c6
working external metadata
bam241 f575283
comment out throughput
bam241 88f96e8
working version
bam241 5eecfa2
removing useless metrics
bam241 42c4537
update usage
bam241 a750f27
Merge remote-tracking branch 'upstream/master' into metadata
bam241 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -400,14 +400,104 @@ def annual_electricity_generated_by_agent(elec): | |
'AgentId': elec.AgentId, | ||
'Year': elec.Time.apply(lambda x: x//12), | ||
'Energy': elec.Value.apply(lambda x: x/12)}, | ||
columns=['SimId', 'AgentId', 'Year', 'Energy']) | ||
columns=['SimId', 'AgentId', 'Year', 'Energy']) | ||
el_index = ['SimId', 'AgentId', 'Year'] | ||
elec = elec.groupby(el_index).sum() | ||
rtn = elec.reset_index() | ||
return rtn | ||
|
||
del _egdeps, _egschema | ||
|
||
# Usage | ||
_egdeps = ['Metadata', 'TimeList', 'AgentEntry', 'TimeSeriesPower', 'TimeSeriesEnrichmentSWU', 'TimeSeriesThroughput'] | ||
|
||
_egschema = [ | ||
('SimId', ts.UUID), | ||
('AgentId', ts.INT), | ||
('Time', ts.INT), | ||
('Keyword', ts.STRING), | ||
('Value', ts.DOUBLE) | ||
] | ||
|
||
@metric(name='Usage', depends=_egdeps, schema=_egschema) | ||
def usage_by_agent(metadata, time, agents_entry, power, SWU, throughput_ts): | ||
""" | ||
""" | ||
|
||
deployment = metadata[ metadata['Type'] == "deployment" ] | ||
decom = metadata[ metadata['Type'] == "decommission" ] | ||
timestep = metadata[ metadata['Type'] == "timestep" ] | ||
throughput_meta = metadata[ metadata['Type'] == "throughput" ] | ||
|
||
|
||
# Deployement | ||
dep_agent = agents_entry[agents_entry['AgentId'].isin(deployment['AgentId'])] | ||
_tmp = pd.merge(deployment[['SimId', 'AgentId','Keyword', 'Value']], dep_agent, on=['SimId', 'AgentId']) | ||
|
||
|
||
deployment_use = pd.DataFrame(data={'SimId': _tmp.SimId, | ||
'AgentId': _tmp.AgentId, | ||
'Time': _tmp.EnterTime, | ||
'Keyword': _tmp.Keyword, | ||
'Value':_tmp.Value.astype(float)}, | ||
columns=['SimId', 'AgentId', 'Time', 'Keyword', 'Value']) | ||
rtn = deployment_use.copy() | ||
|
||
# Decommision | ||
decom_agent = agents_entry[agents_entry['AgentId'].isin(decom['AgentId'])] | ||
decom_agent = decom_agent.reset_index(drop=True) | ||
decom_agent['ExitTime'] = decom_agent['EnterTime'] + decom_agent['Lifetime'] | ||
_tmp = pd.merge(decom[['SimId', 'AgentId','Keyword', 'Value']], decom_agent, on=['SimId', 'AgentId']) | ||
decom_use = pd.DataFrame(data={'SimId': _tmp.SimId, | ||
'AgentId': _tmp.AgentId, | ||
'Time': _tmp.ExitTime, | ||
'Keyword': _tmp.Keyword, | ||
'Value':_tmp.Value.astype(float)}, | ||
columns=['SimId', 'AgentId', 'Time', 'Keyword', 'Value']) | ||
rtn = pd.concat([rtn, decom_use], ignore_index=True) | ||
|
||
# TimeStep | ||
timestep_agent = agents_entry[agents_entry['AgentId'].isin(timestep['AgentId'])] | ||
timestep_agent = timestep_agent.reset_index(drop=True) | ||
timestep_agent['ExitTime'] = timestep_agent['EnterTime'] + timestep_agent['Lifetime'] | ||
timestep_tmp = pd.DataFrame(data={'SimId': _tmp.SimId, | ||
'AgentId': _tmp.AgentId, | ||
'EnterTime': _tmp.EnterTime, | ||
'ExitTime': _tmp.ExitTime , | ||
'Keyword': _tmp.Keyword, | ||
'Value':_tmp.Value.astype(float)}, | ||
columns=['SimId', 'AgentId', 'EnterTime', 'ExitTime', 'Keyword', 'Value']) | ||
time_step_data = [] | ||
for index, row in timestep_tmp.iterrows(): | ||
for i in range(row['EnterTime'], row['ExitTime']): | ||
time_step_data.append( (row['SimId'], | ||
row['AgentId'], | ||
i, | ||
row['Keyword'], | ||
row['Value'])) | ||
timestep_use = pd.DataFrame(time_step_data, columns=['SimId', 'AgentId', 'Time', 'Keyword', 'Value']) | ||
rtn = pd.concat([rtn, timestep_use], ignore_index=True) | ||
|
||
# def get_throughput_timeseries(throughput_df, throughput_meta): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete these commented functions? |
||
# if throughput_df is not None: | ||
# _tmp = pd.merge(throughput_meta[['SimId', 'AgentId','Keyword', 'Value']], throughput_df, on=['SimId', 'AgentId']) | ||
# _tmp['Value_y'] = _tmp.Value_x.astype(float)*_tmp.Value_y | ||
# _tmp.drop(columns=['Value_x'], inplace=True) | ||
# _tmp.rename(columns={"Value_y": "Value"}, inplace=True) | ||
# return _tmp | ||
# else: | ||
# return pd.DataFrame() | ||
# | ||
# rtn = pd.concat([rtn, get_throughput_timeseries(power, throughput_meta)], ignore_index=True) | ||
# rtn = pd.concat([rtn, get_throughput_timeseries(SWU, throughput_meta)], ignore_index=True) | ||
# rtn = pd.concat([rtn, get_throughput_timeseries(throughput_ts, throughput_meta)], ignore_index=True) | ||
|
||
|
||
return rtn | ||
|
||
del _egdeps, _egschema | ||
|
||
|
||
# | ||
# Not a metric, not a root metric metrics | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More documentation required for these new sections. i don't really know what they mean