Grid Filters - exact match

Hi there,

I was trying to use the grid_filters for post processing of annual results to get results by room name which I had set up when creating the daylight models.

I came across a case where 2 room names were similar 'Studio and ‘LStudio’. When I used the filter ‘Studio’ it was also giving me the results for the ‘LStudio’. I know an easy fix would be to make sure the room names don’t contain any of the other room names, however this was already after annual daylight simulations on 400+ rooms, so it wasn’t feasible to go back and alter the room naming convention.

I had a look in the code in C:…ladybug_tools\python\Lib\site-packages\honeybee_radiance\writer.py and changed the code on line 819 from:

if re.search(pattern, id_):

to:

if re.match(pattern, id_):

after doing a bit of reading on re — Regular expression operations — Python 3.10.6 documentation

This has solved my problem, but I’m not very familiar with regular expression matching so would welcome your opinion on this case.

Thanks,
Andrew

1 Like

Hi @AKomar,

If you want to search for an exact string you can add ^ (start of the string) and $ (end of the string), e.g., ^Studio$.

With the new version of the annual-daylight recipe the post processing is executed in a CLI command. Since the grid_filter_ input is passed to the CLI command we can’t use the ^ character without an escape character which happens to also be ^. So you would have to type ^^Studio$ in grid_filter_.

1 Like

Hi @mikkel,

Thanks for your response. In my initial post I forgot to mention that the room type names have numbers appended to them, so for example i would have a list of room names as the below:

Studio1
Studio2
Studio3
LStudio1
LStudio2
LStudio3

So I’m not looking for an exact match but would want to filter the results by Studios and LStudios if that make sense.

Apologies for not explaining the nuance of the issue in the first instance.

Andrew

Hi @AKomar,

The most simple way would be to remove $. In your case you could even skip everything past the first letter, and simply use ^^S or ^^L.