def dklCart2rgb(LUM, LM, S, conversionMatrix=None):
 NxNx3 = list(LUM.shape)
 NxNx3.append(3)
 dkl_cartesian = numpy.asarray([LUM.reshape([(-1)]), LM.reshape([(-1)]), S.reshape([(-1)])])
 if (conversionMatrix is None):
  conversionMatrix = numpy.asarray([[1.0, 1.0, (-0.1462)], [1.0, (-0.39), 0.2094], [1.0, 0.018, (-1.0)]])
 rgb = numpy.dot(conversionMatrix, dkl_cartesian)
 return numpy.reshape(numpy.transpose(rgb), NxNx3)

def dklCart2rgb ( LUM , LM , S , conversionMatrix = None ) : NxNx3 = list ( LUM . shape ) NxNx3 . append ( 3 ) dkl_cartesian = numpy . asarray ( [ LUM . reshape ( [ ( - 1 ) ] ) , LM . reshape ( [ ( - 1 ) ] ) , S . reshape ( [ ( - 1 ) ] ) ] ) if ( conversionMatrix is None ) : conversionMatrix = numpy . asarray ( [ [ 1.0 , 1.0 , ( - 0.1462 ) ] , [ 1.0 , ( - 0.39 ) , 0.2094 ] , [ 1.0 , 0.018 , ( - 1.0 ) ] ] ) rgb = numpy . dot ( conversionMatrix , dkl_cartesian ) return numpy . reshape ( numpy . transpose ( rgb ) , NxNx3 )
like dkl2rgb except that it uses cartesian coords rather than spherical coords for dkl .