Ejemplo n.º 1
0
    def setUp(self):
        # instantiate gensky with monthdayhour
        self.gensky_month_day = Gensky(month_day_hour=(11, 12, '11EST'))

        # instantiate gensky params and add some values
        gensky_param1 = GenskyParameters()
        gensky_param1.cloudy_sky = True
        gensky_param1.ground_reflect = 0.2

        # add params to gensky class.
        self.gensky_month_day.gensky_parameters = gensky_param1

        # instantiate another gensky, with altitude and azimuth angles.
        self.gensky_alt_azi = Gensky()
        gensky_param2 = GenskyParameters(altitude_azimuth=('32 11'),
                                         sunny_sky=True)
        self.gensky_alt_azi.gensky_parameters = gensky_param2
Ejemplo n.º 2
0
class GenskyTestCase(unittest.TestCase):
    """Test for (honeybee/radiance/command/gensky.py)."""

    # preparing to test.
    def setUp(self):
        # instantiate gensky with monthdayhour
        self.gensky_month_day = Gensky(month_day_hour=(11, 12, '11EST'))

        # instantiate gensky params and add some values
        gensky_param1 = GenskyParameters()
        gensky_param1.cloudy_sky = True
        gensky_param1.ground_reflect = 0.2

        # add params to gensky class.
        self.gensky_month_day.gensky_parameters = gensky_param1

        # instantiate another gensky, with altitude and azimuth angles.
        self.gensky_alt_azi = Gensky()
        gensky_param2 = GenskyParameters(altitude_azimuth=('32 11'),
                                         sunny_sky=True)
        self.gensky_alt_azi.gensky_parameters = gensky_param2

    def tearDown(self):
        # Checking radstrings only, so nothing gets written to file.
        pass

    def test_default_values(self):
        "Test the command runs correctly"
        # This test confirm cloudy_sky, ground_reflect, month_day_hour and default
        # name are set correctly
        gensky_month_day_string = self.gensky_month_day.to_rad_string()
        assert 'gensky 11 12 11EST' in gensky_month_day_string
        assert ' -c ' in gensky_month_day_string
        assert ' -g 0.2 ' in gensky_month_day_string
        assert gensky_month_day_string.endswith(' > untitled.sky')

        # This test confirm sunny_sky and solar angle are set correctly through
        # GenSkyParameters() class
        gensky_alt_azi_string = self.gensky_alt_azi.gensky_parameters.to_rad_string(
        )
        assert '+s' in gensky_alt_azi_string
        assert '-ang 32.0 11.0' in gensky_alt_azi_string
class GenskyTestCase(unittest.TestCase):
    """Test for (honeybee/radiance/command/gensky.py)."""

    # preparing to test.
    def setUp(self):
        # instantiate gensky with monthdayhour
        self.genskyMonthDay = Gensky(monthDayHour=(11, 12, '11EST'))

        # instantiate gensky params and add some values
        genskyParam1 = GenskyParameters()
        genskyParam1.cloudySky = True
        genskyParam1.groundReflect = 0.2

        # add params to gensky class.
        self.genskyMonthDay.genskyParameters = genskyParam1

        # instantiate another gensky, with altitude and azimuth angles.
        self.genskyAltAzi = Gensky()
        genskyParam2 = GenskyParameters(altitudeAzimuth=('32 11'),
                                        sunnySky=True)
        self.genskyAltAzi.genskyParameters = genskyParam2

    def tearDown(self):
        # Checking radstrings only, so nothing gets written to file.
        pass

    def test_default_values(self):
        "Test the command runs correctly"
        genskyMonthDayString = self.genskyMonthDay.toRadString()
        print(genskyMonthDayString)
        # This prints gensky 11 12 11EST -ang 32 11 -g 0.2 +s -c
        # The -ang 32 11 and +s where not assigned for this instance but they
        # pop up for some reason.

        genskyAltAziString = self.genskyAltAzi.genskyParameters.toRadString()
        self.assertEqual(genskyAltAziString, '-ang 32.0 11.0 +s')
Ejemplo n.º 4
0
def run2Phase(calculationType='annual'):
    if calculationType == 'annual':
        weaFile = Epw2wea(epwFile='test.epw', outputWeaFile=r'temp/test.wea')
        weaFile.execute()
        gendayParam = GendaymtxParameters()
        gendayParam.skyDensity = 4

        genday = Gendaymtx(weaFile=r'temp/test.wea', outputName=r'temp/day.smx')
        genday.gendaymtxParameters = gendayParam
        # genday.execute()
        skyVector = r'temp/day.smx'
    else:
        gensk = Gensky()
        gensk.monthDayHour = (11, 11, 11)
        gensk.outputFile = 'temp/sky.rad'
        gensk.execute()

        genskv = Genskyvec()
        genskv.inputSkyFile = r'temp/sky.rad'
        genskv.outputFile = r'temp/sky.vec'
        genskv.skySubdivision = 4
        genskv.execute()
        skyVector = r'temp/sky.vec'

    #
    # Step2: Generate daylight coefficients using rfluxmtx.
    rfluxPara = RfluxmtxParameters()
    rfluxPara.irradianceCalc = False
    rfluxPara.ambientAccuracy = 0.1
    rfluxPara.ambientDivisions = 10
    rfluxPara.ambientBounces = 1
    rfluxPara.limitWeight = 0.1
    rfluxPara.quality = 0
    rflux = Rfluxmtx()
    rflux.sender = '-'
    skyFile = rflux.defaultSkyGround(r'temp/rfluxSky.rad',skyType='r4')
    rflux.receiverFile = skyFile
    rflux.rfluxmtxParameters = rfluxPara
    rflux.radFiles = [r"room.mat",
                      r"room.rad"]

    rflux.pointsFile = r"indoor_points.pts"
    rflux.outputMatrix = r"temp/dayCoeff.dc"
    rflux.execute()


    mtx1 = Rmtxop(matrixFiles=(os.path.abspath(r'temp/dayCoeff.dc'),
                               os.path.abspath(skyVector)),
                  outputFile=r'temp/illuminance.tmp')

    mtx1.execute()


    mtx2Param = RmtxopParameters()
    mtx2Param.outputFormat = 'a'
    mtx2Param.combineValues = (47.4, 119.9, 11.6)
    # mtx2Param.transposeMatrix = True
    mtx2 = Rmtxop(matrixFiles=[r'temp/illuminance.tmp'], outputFile=r'temp/illuminance.ill')
    mtx2.rmtxopParameters = mtx2Param
    mtx2.execute()

    with open(r'temp/illuminance.ill') as illFile:
        for lines in illFile:
            try:
                print(map(float, lines.split()))
            except ValueError:
                pass
Ejemplo n.º 5
0
def run3phase(phasesToCalculate={'v':True,'t':True,'d':True,'s':True},
              calculationType='annual',epwFile=None,tmatrixFile=None,
              hdrResultsFileName=None,numProcessors=1,timeStamp=None):


    if phasesToCalculate['v']:
        # Step1: Create the view matrix.
        rfluxPara = RfluxmtxParameters()
        rfluxPara.ambientAccuracy = 0.1
        rfluxPara.ambientBounces = 10
        # using this for a quicker run
        rfluxPara.ambientBounces = 5

        rfluxPara.ambientDivisions = 65536
        # using this for a quicker run
        # rfluxPara.ad = 1000

        rfluxPara.limitWeight = 1E-5
        # rfluxPara.lw = 1E-2

        #step 1.1 Invert glazing surface with xform so that it faces inwards
        xfrPara = XformParameters()
        xfrPara.invertSurfaces = True

        xfr = Xform()
        xfr.xformParameters = xfrPara
        xfr.radFile = 'glazing.rad'
        xfr.outputFile = 'glazingI.rad'
        xfr.execute()

        vwrParaDim = VwraysParameters()
        vwrParaDim.calcImageDim = True
        vwrParaDim.xResolution = 800
        vwrParaDim.yResolution = 800

        vwrDim = Vwrays()
        vwrDim.vwraysParameters = vwrParaDim
        vwrDim.viewFile = 'viewSouth1.vf'
        vwrDim.outputFile = r'temp/viewSouthDimensions.txt'
        vwrDim.execute()

        vwrParaSamp = VwraysParameters()
        vwrParaSamp.xResolution = 800
        vwrParaSamp.yResolution = 800
        vwrParaSamp.samplingRaysCount = 9
        # vwrParaSamp.samplingRaysCount = 3
        vwrParaSamp.jitter = 0.7

        vwrSamp = Vwrays()
        vwrSamp.vwraysParameters = vwrParaSamp
        vwrSamp.viewFile = 'viewSouth1.vf'
        vwrSamp.outputFile = r'temp/viewSouthRays.txt'
        vwrSamp.outputDataFormat = 'f'
        vwrSamp.execute()



        rflux = Rfluxmtx()
        rflux.sender = '-'

        #Klems full basis sampling and the window faces +Y
        recCtrlPar = rflux.ControlParameters(hemiType='kf',hemiUpDirection='+Z')
        rflux.receiverFile = rflux.addControlParameters('glazingI.rad',
                                                        {'Exterior_Window':recCtrlPar})
        rflux.outputDataFormat = 'fc'
        rflux.verbose = True
        rflux.rfluxmtxParameters = rfluxPara
        rflux.viewInfoFile = r'temp/viewSouthDimensions.txt'
        rflux.viewRaysFile = r'temp/viewSouthRays.txt'
        rflux.radFiles = ['room.mat','room.rad','glazing.rad']
        rflux.outputFilenameFormat = r'temp/%03d.hdr'
        rflux.samplingRaysCount = 9
        # rflux.samplingRaysCount = 3
        rflux.numProcessors = numProcessors
        rflux.execute()

    vMatrix = r'temp/vmatrix.vmx'



    #Step2: Assign T matrix from precalculated XML files.
    tMatrix = tmatrixFile or r'xmls/clear.xml'

    if phasesToCalculate['d']:
        #Step3: Create D matrix.
        rfluxPara = RfluxmtxParameters()
        rfluxPara.ambientAccuracy = 0.1
        rfluxPara.ambientDivisions = 1024
        rfluxPara.ambientBounces = 2
        rfluxPara.limitWeight = 0.0000001

        rflux2 = Rfluxmtx()
        rflux2.numProcessors = numProcessors
        rflux2.samplingRaysCount = 1000
        rflux2.sender = 'glazingI.rad_m'
        skyFile = rflux2.defaultSkyGround(r'temp/rfluxSky.rad', skyType='r4')
        rflux2.receiverFile = skyFile
        rflux2.rfluxmtxParameters = rfluxPara
        rflux2.radFiles = [r"room.mat",
                          r"room.rad",
                          'glazing.rad']
        rflux2.outputMatrix = r"temp/dmatrix.dmx"
        rflux2.execute()

    dMatrix = r"temp/dmatrix.dmx"


    #Step4a: Create the sky vector.

    #Step4a.1: Create a sky defintion
    # Step s: Creating the sky matrix
    if phasesToCalculate['s']:
        if calculationType == 'annual':
            weaFile = Epw2wea(epwFile=epwFile or 'test.epw', outputWeaFile=r'temp/test.wea')
            weaFile.execute()

            gendayParam = GendaymtxParameters()
            gendayParam.skyDensity = 4

            genday = Gendaymtx(weaFile=r'temp/test.wea', outputName=r'temp/day.smx')
            genday.gendaymtxParameters = gendayParam
            genday.execute()

            skyVector = r'temp/day.smx'
        else:
            genskPar = GenskyParameters()
            gensk = Gensky()
            gensk.monthDayHour = timeStamp or (11,11,11)
            gensk.outputFile = 'temp/sky.rad'
            gensk.execute()

            genskv = Genskyvec()
            genskv.inputSkyFile = r'temp/sky.rad'
            genskv.outputFile = r'temp/sky.vec'
            genskv.skySubdivision = 4
            genskv.execute()
            skyVector = r'temp/sky.vec'
    else:
        skyVector = r'temp/sky.vec'



    # Step5: Generate results
    dct = Dctimestep()
    dct.tmatrixFile = tMatrix
    dct.vmatrixSpec = r'temp/%03d.hdr'
    dct.dmatrixFile = dMatrix
    dct.skyVectorFile = skyVector
    dct.outputFileName = hdrResultsFileName or r'temp/results.hdr'
    dct.execute()

    return 'temp/results.txt'