pywincalc.BSDFBasisType.QUARTER)

# Download some product data from the IGSDB.  This example gets a generic single clear 3mm glazing (NFRC 102),
# a venetian blind manufactured by Pella (CGDB ID 3000) and a perforated screen manufacturerd by Solar Comfort
# (CGDB ID 18000)
generic_clear_3mm_glass_igsdb_id = 363
slim_white_pella_venetian_blind_igsdb_id = 14684

generic_clear_3mm_glass_igsdb_response = requests.get(
    url_single_product.format(id=generic_clear_3mm_glass_igsdb_id),
    headers=headers)
slim_white_pella_venetian_blind_igsdb_response = requests.get(
    url_single_product.format(id=slim_white_pella_venetian_blind_igsdb_id),
    headers=headers)

generic_clear_3mm_glass = pywincalc.parse_json(
    generic_clear_3mm_glass_igsdb_response.content)
slim_white_pella_venetian_blind = pywincalc.parse_json(
    slim_white_pella_venetian_blind_igsdb_response.content)

# Create a glazing system using the NFRC U environment in order to get NFRC U results
# U and SHGC can be caculated for any given environment but in order to get results
# The NFRC U and SHGC environments are provided as already constructed environments and Glazing_System
# defaults to using the NFRC U environments

glazing_system_u_environment = pywincalc.GlazingSystem(
    optical_standard=optical_standard,
    solid_layers=[slim_white_pella_venetian_blind, generic_clear_3mm_glass],
    gap_layers=[gap_1],
    width_meters=glazing_system_width,
    height_meters=glazing_system_height,
    environment=pywincalc.nfrc_u_environments(),
# Download some product data from the IGSDB.  This example gets a generic single clear 3mm glazing (NFRC 102),
# a venetian blind manufactured by Pella (CGDB ID 3000) and a perforated screen manufacturerd by Solar Comfort
# (CGDB ID 18000)
generic_clear_3mm_glass_igsdb_id = 363
slim_white_pella_venetian_blind_igsdb_id = 14684
thermeshade_perforated_screen_igsdb_id = 14990

generic_clear_3mm_glass_igsdb_response = requests.get(
    url_single_product.format(id=generic_clear_3mm_glass_igsdb_id),
    headers=headers)
thermeshade_perforated_screen_igsdb_response = requests.get(
    url_single_product.format(id=thermeshade_perforated_screen_igsdb_id),
    headers=headers)

generic_clear_3mm_glass = pywincalc.parse_json(
    generic_clear_3mm_glass_igsdb_response.content)
thermeshade_perforated_screen = pywincalc.parse_json(
    thermeshade_perforated_screen_igsdb_response.content)

# Create a glazing system using the NFRC U environment in order to get NFRC U results
# U and SHGC can be caculated for any given environment but in order to get results
# The NFRC U and SHGC environments are provided as already constructed environments and Glazing_System
# defaults to using the NFRC U environments

glazing_system_u_environment = pywincalc.GlazingSystem(
    optical_standard=optical_standard,
    solid_layers=[thermeshade_perforated_screen, generic_clear_3mm_glass],
    gap_layers=[gap_1],
    width_meters=glazing_system_width,
    height_meters=glazing_system_height,
    environment=pywincalc.nfrc_u_environments(),
    pywincalc.BSDFBasisType.QUARTER)

# Download some product data from the IGSDB.  This example gets a generic single clear 3mm glazing (NFRC 102),
# and a material to use as part of the woven shade.
generic_clear_3mm_glass_igsdb_id = 363

# This is the same material used in the venetian example but could be any material in the igsdb
shade_material_igsdb_id = 14477

generic_clear_3mm_glass_igsdb_response = requests.get(
    url_single_product.format(id=generic_clear_3mm_glass_igsdb_id),
    headers=headers)
shade_material_igsdb_response = requests.get(
    url_single_product.format(id=shade_material_igsdb_id), headers=headers)

generic_clear_3mm_glass = pywincalc.parse_json(
    generic_clear_3mm_glass_igsdb_response.content)

shade_material = pywincalc.parse_json(shade_material_igsdb_response.content)

# Perforated screens need Perforated_Geometry.
# Make a rectangular perforation here.  Other options include circular and square
# Note: While using a string for perforation type is not ideal it is used here because this
# example is mostly using data from the IGSDB for the material and only adding a custom geometry
# For an example where the data is completely custom generated see custom_perforated.py
perforation_type = "rectangular"
spacing_x = 0.01  # 10mm horizontal spacing
spacing_y = 0.02  # 20mm vertical spacing
dimension_x = 0.002  # 2mm perforation in the horizontal direction
dimension_y = 0.003  # 3mm perforation in the vertical direction
geometry = pywincalc.PerforatedGeometry(spacing_x, spacing_y, dimension_x,
                                        dimension_y, perforation_type)
gap_1 = pywincalc.Gap(pywincalc.PredefinedGasType.AIR,
                      .0127)  # .0127 is gap thickness in meters

bsdf_hemisphere = pywincalc.BSDFHemisphere.create(pywincalc.BSDFBasisType.FULL)

generic_clear_3mm_glass_igsdb_id = 363
bsdf_igsdb_id = 14710

generic_clear_3mm_glass_igsdb_response = requests.get(
    url_single_product.format(id=generic_clear_3mm_glass_igsdb_id),
    headers=headers)

bsdf_igsdb_response = requests.get(
    url_single_product_datafile.format(id=bsdf_igsdb_id), headers=headers)

clear_3 = pywincalc.parse_json(generic_clear_3mm_glass_igsdb_response.content)

# The BSDF data is currently stored as XML on igsdb.lbl.gov.  As a result it needs to be
# parsed using the xml string parser instead of the json parser
bsdf_shade = pywincalc.parse_bsdf_xml_string(bsdf_igsdb_response.content)

# Create a glazing system using the NFRC U environment in order to get NFRC U results
# U and SHGC can be caculated for any given environment but in order to get results
# The NFRC U and SHGC environments are provided as already constructed environments and Glazing_System
# defaults to using the NFRC U environments
glazing_system_u_environment = pywincalc.GlazingSystem(
    optical_standard=optical_standard,
    solid_layers=[clear_3, bsdf_shade],
    gap_layers=[gap_1],
    width_meters=glazing_system_width,
    height_meters=glazing_system_height,