### Install NYISOToolkit Source: https://github.com/m4rz910/nyisotoolkit/blob/master/README.md Install the NYISOToolkit package using pip. This command installs directly from the GitHub repository. ```python pip install git+https://github.com/m4rz910/NYISOToolkit#egg=nyisotoolkit ``` -------------------------------- ### Generate Price PDFs Source: https://github.com/m4rz910/nyisotoolkit/blob/master/docs/tutorials/3. nyisovis pdfs.ipynb Generates probability density functions for prices, with options for real-time data and cumulative distribution. ```python for rtorda in [False, True]: for c in [False, True]: nv.price_pdf(rt=rtorda, cumulative=c) ``` -------------------------------- ### Import Libraries Source: https://github.com/m4rz910/nyisotoolkit/blob/master/docs/tutorials/3. nyisovis pdfs.ipynb Imports necessary libraries for data visualization and the nyisotoolkit. ```python import matplotlib.pyplot as plt import seaborn as sns import pandas as pd from nyisotoolkit import NYISOVis, NYISOData ``` -------------------------------- ### Generate Demand PDFs Source: https://github.com/m4rz910/nyisotoolkit/blob/master/docs/tutorials/3. nyisovis pdfs.ipynb Generates probability density functions for demand, with an option to plot the cumulative distribution. ```python for c in [False, True]: nv.demand_pdf(cumulative=c) ``` -------------------------------- ### Generate Price Delta PDFs Source: https://github.com/m4rz910/nyisotoolkit/blob/master/docs/tutorials/3. nyisovis pdfs.ipynb Generates probability density functions for the difference in prices, with an option to plot the cumulative distribution. ```python for c in [False, True]: nv.price_delta_pdf(cumulative=c) ``` -------------------------------- ### Import Libraries and Generate Basic Plots Source: https://github.com/m4rz910/nyisotoolkit/blob/master/notebooks/simple.ipynb Imports required libraries and calls the basic_plots function to generate visualizations. Set 'redownload' to True to force data redownload. ```python import pytest from datetime import datetime import pytz import matplotlib.pyplot as plt from nyisotoolkit import NYISOVis from nyisotoolkit.nyisovis.nyisovis import basic_plots, statistical_plots from nyisotoolkit.nyisodata.utils import current_year basic_plots({"redownload":False, 'year': 2024}) ``` -------------------------------- ### Construct NYISO Databases Source: https://github.com/m4rz910/nyisotoolkit/blob/master/README.md Construct local databases for specified years and datasets. This function can redownload data, reconstruct databases, and optionally create CSV files. ```python years = range(2022,2024) datasets = ['load_h','interface_flows_5m'] NYISOData.construct_databases(years=years, datasets=datasets, redownload=True, reconstruct=True, create_csvs=False) ``` -------------------------------- ### Calculate Covariance Between Renewables and Prices Source: https://github.com/m4rz910/nyisotoolkit/blob/master/docs/ideas/wind_and_solar_covariance_risk.ipynb Fetches historical fuel mix and load-weighted LBMP data for a given year and time resolution (RT or DA). It calculates the energy generated by specified renewable sources and aligns it with the corresponding prices. Asserts that the indices of both datasets are compatible before returning them. ```python from nyisotoolkit import NYISOData from nyisotoolkit.nyisostat.nyisostat import table_load_weighted_price import matplotlib.pyplot as plt import seaborn as sns import pandas as pd def covariance(year, sources, rt): lw_lbmp = table_load_weighted_price(year=year, rt=rt).iloc[:,0] #convert to series fuel_mix = NYISOData(dataset="fuel_mix_5m", year=year).df.tz_convert('US/Eastern') # MW fuel_mix = (fuel_mix[sources].sum(axis="columns")*1/12) #MW->MWh if not rt: fuel_mix = fuel_mix.resample("H").sum() assert lw_lbmp.index.isin(fuel_mix.index).any(), "Indices are not the same" assert len(lw_lbmp.index)==len(fuel_mix.index), "Indices are not the same size" return fuel_mix, lw_lbmp ``` -------------------------------- ### Import NYISOData Class Source: https://github.com/m4rz910/nyisotoolkit/blob/master/docs/tutorials/1. nyisodata example.ipynb Import the necessary class from the nyisotoolkit library. ```python from nyisotoolkit import NYISOData ``` -------------------------------- ### Initialize NYISOVis Source: https://github.com/m4rz910/nyisotoolkit/blob/master/docs/tutorials/3. nyisovis pdfs.ipynb Initializes the NYISOVis object for a specific year. ```python nv = NYISOVis(year=2020) ``` -------------------------------- ### Generate Carbon Free Timeseries Visualization Source: https://github.com/m4rz910/nyisotoolkit/blob/master/README.md Initializes the NYISOVis object and generates a carbon-free energy timeseries plot. Figures are saved to a default directory, which can be customized. ```python from nyisotoolkit import NYISOData, NYISOStat, NYISOVis nv = NYISOVis(year='2021') #figures saved in nyisotoolkit/nyisovis/visualization folder by default. nv.fig_carbon_free_timeseries(f='D') # daily (D) or monthy (M) frequency is recommended print(f"Figures saved by default to: {nv.out_dir} \nYou can change this by passing a pathlib object to the out_dir parameter in the NYISOVis object initialization.") ``` -------------------------------- ### Load Hourly Load Data Source: https://github.com/m4rz910/nyisotoolkit/blob/master/README.md Load hourly load data for a specific year. The data is returned in UTC and can be converted to local time if needed. ```python from nyisotoolkit import NYISOData, NYISOStat, NYISOVis df = NYISOData(dataset='load_h', year='2024').df # year argument in local time, but returns dataset in UTC #If you need to work with data in local time, then convert time zone df = df.tz_convert('US/Eastern') ``` -------------------------------- ### Fetch and Convert Load Data Source: https://github.com/m4rz910/nyisotoolkit/blob/master/docs/tutorials/1. nyisodata example.ipynb Fetch historical load data for a given year and convert it to Eastern Time. This snippet shows how to initialize NYISOData with a dataset and year, access the DataFrame, and perform timezone conversion. ```python df = NYISOData(dataset="load_h", year="2019").df #UTC df = df.tz_convert("US/Eastern") df.head(5) ``` -------------------------------- ### Visualize Renewable Covariance Risk Source: https://github.com/m4rz910/nyisotoolkit/blob/master/docs/ideas/wind_and_solar_covariance_risk.ipynb Generates scatter plots to visualize the covariance risk between renewable energy sources and electricity prices. It iterates through different renewable sources and time resolutions (RT/DA), setting appropriate plot titles and labels. Requires matplotlib and seaborn for plotting. ```python def renewable_covariance(year, rt): scatter_kwargs = {"x":None, "y":None, "hue":None, "style":None, "size":None, "data":None, "palette":None, "hue_order":None, "hue_norm":None, "sizes":None, "size_order":None, "size_norm":None, "markers":True, "style_order":None, "x_bins":None, "y_bins":None, "units":None, "estimator":None, "ci":95, "n_boot":1000, "alpha":None, "x_jitter":None, "y_jitter":None, "legend":'auto', "ax":None} for source in ["Wind", "Other Renewables"]: da_rt = "RT" if rt else "DA" ax_kwargs = {"title":f'Covariance Risk of {source} ({year})', "xlabel":f"{source} [MWh]","ylabel":f"State-wide Average {da_rt} Price [$/MWh]", "xlim":None, "ylim":None} fuel_mix, lw_lbmp = covariance(year=year, sources=[source], rt=rt) scatter_kwargs.update({"x": fuel_mix.values, "y": lw_lbmp.values}) fig, ax = plt.subplots(figsize=(6,3), dpi=300) sns.scatterplot(**scatter_kwargs) ax.set(**ax_kwargs) for rtorda in [False, True]: renewable_covariance(year=2019, rt=rtorda) ``` -------------------------------- ### UserWarning from set_ticklabels Source: https://github.com/m4rz910/nyisotoolkit/blob/master/notebooks/simple.ipynb This warning indicates a potential issue with tick label settings in matplotlib, often related to fixed tick locators. ```python Output: /home/m4rz177/Documents/NYISOToolkit/nyisotoolkit/nyisovis/nyisovis.py:395: UserWarning: set_ticklabels() should only be used with a fixed number of ticks, i.e. after set_ticks() or using a FixedLocator. cb1.ax.set_yticklabels([i for i in range(0,120,20)]) ``` -------------------------------- ### Basic Plot Output Figure Size Source: https://github.com/m4rz910/nyisotoolkit/blob/master/notebooks/simple.ipynb Represents a matplotlib figure with a size of 900x1800 pixels and one axes. ```text Result:
``` -------------------------------- ### Basic Plot Output Figure Size Source: https://github.com/m4rz910/nyisotoolkit/blob/master/notebooks/simple.ipynb Represents a matplotlib figure with a size of 1800x900 pixels and one axes. ```text Result:
``` -------------------------------- ### Basic Plot Output Figure Size Source: https://github.com/m4rz910/nyisotoolkit/blob/master/notebooks/simple.ipynb Represents a matplotlib figure with a size of 1800x900 pixels and two axes. ```text Result:
``` -------------------------------- ### Basic Plot Output Figure Size Source: https://github.com/m4rz910/nyisotoolkit/blob/master/notebooks/simple.ipynb Represents a matplotlib figure with a size of 1800x1800 pixels and two axes. ```text Result:
``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.