Spaces:
Paused
Paused
Download modules/capacity.py from Rachel7/hvac_fable: direct link, hf CLI and curl.
- Browser
- Download file 2.04 kB
-
https://huggingface.co/spaces/Rachel7/hvac_fable/resolve/main/modules/capacity.py
- Command line
-
hf download hf://spaces/Rachel7/hvac_fable/modules/capacity.py
-
curl -L -o capacity.py https://huggingface.co/spaces/Rachel7/hvac_fable/resolve/main/modules/capacity.py
2.04 kB
| """Map an HVAC unit model number to its nominal cooling capacity. | |
| Daikin VRV/residential indoor units encode capacity (in kBTU/h) directly in the | |
| model number, e.g.: | |
| FXSQ24TAVJU -> 24 kBTU/h FXFQ36TAVJU -> 36 kBTU/h | |
| FTXS09LVJU -> 9 kBTU/h FXAQ07PVJU -> 7.5 kBTU/h | |
| Mitsubishi MSZ/PEFY etc. use the same 2-3 digit capacity code. This is confirmed | |
| by Mitsubishi_Daikin_Indoor_HVAC_Units_v1.xlsx ("Available Capacities (kBTU/h)" | |
| columns line up with the model-number codes), so we parse the code directly and | |
| fall back to 0 when a model is missing/unparseable. | |
| """ | |
| from __future__ import annotations | |
| import re | |
| BTU_PER_KBTU = 1000 | |
| KW_PER_BTU = 0.00029307107 # 1 BTU/h = 0.000293 kW | |
| # Capacity codes that aren't a literal kBTU value (rounded model codes). | |
| _CODE_OVERRIDE = {"07": 7.5} | |
| def _capacity_code(model: str) -> int | None: | |
| """Pull the 2-3 digit capacity code that follows the series letters.""" | |
| if not model: | |
| return None | |
| up = model.upper() | |
| m = re.search(r"[A-Z]{2,4}(\d{2,3})", up) | |
| if not m: | |
| # Mitsubishi CITY MULTI P-series: PKFY-P08NHMU-E2 → P08 → 8 kBTU/h. | |
| # The code sits after '-P', so the letters-then-digits rule misses it. | |
| m = re.search(r"-P(\d{2,3})", up) | |
| return m.group(1) if m else None | |
| def capacity_for_model(model: str) -> dict: | |
| """Return {'kbtu', 'capacity_btu', 'capacity_kw'} for a model number. | |
| All zero when it can't be determined.""" | |
| code = _capacity_code(model) | |
| if code is None: | |
| return {"kbtu": 0, "capacity_btu": 0, "capacity_kw": 0.0} | |
| kbtu = _CODE_OVERRIDE.get(code, float(int(code))) | |
| btu = kbtu * BTU_PER_KBTU | |
| return {"kbtu": kbtu, "capacity_btu": int(btu), | |
| "capacity_kw": round(btu * KW_PER_BTU, 2)} | |
| def capacity_for_tag(tag: str, schedule: dict) -> dict: | |
| """Look up a tag's model in the schedule dict, then its capacity.""" | |
| info = schedule.get(tag) or {} | |
| return capacity_for_model(info.get("model_number") or "") | |