# MixNet: Towards Effective and Efficient UHD Low-Light Image Enhancement

Chen Wu1 Zhuoran Zheng2∗ Xiuyi Jia2&Wenqi Ren3
1University of Science and Technology of China
2Nanjing University of Science and Technologyn
3Sun Yat-sen University
<EMAIL_ADDRESS>
###### Abstract

With the continuous advancement of imaging devices, the prevalence of Ultra-
High-Definition (UHD) images is rising. Although many image restoration
methods have achieved promising results, they are not directly applicable to
UHD images on devices with limited computational resources due to the
inherently high computational complexity of UHD images. In this paper, we
focus on the task of low-light image enhancement (LLIE) and propose a novel
LLIE method called MixNet, which is designed explicitly for UHD images. To
capture the long-range dependency of features without introducing excessive
computational complexity, we present the Global Feature Modulation Layer
(GFML). GFML associates features from different views by permuting the feature
maps, enabling efficient modeling of long-range dependency. In addition, we
also design the Local Feature Modulation Layer (LFML) and Feed-forward Layer
(FFL) to capture local features and transform features into a compact
representation. This way, our MixNet achieves effective LLIE with few model
parameters and low computational complexity. We conducted extensive
experiments on both synthetic and real-world datasets, and the comprehensive
results demonstrate that our proposed method surpasses the performance of
current state-of-the-art methods. The code will be available at
https://github.com/zzr-idam/MixNet.

##  1 Introduction

In recent years, high-resolution imaging has experienced significant
advancements due to the emergence of sophisticated imaging sensors and
displays. This has led to a rapid evolution of Ultra-High-Definition (UHD)
imaging technology. However, the inherent high-resolution characteristics of
UHD images make them more susceptible to noise during the imaging process.
Additionally, the increased number of pixels in UHD images challenges the
efficiency of existing image processing methods. These undoubtedly affect the
quality of UHD imaging.

In this paper, we focus on the task of UHD low-light image enhancement (LLIE).
Images captured under low-light conditions usually exhibit significant
degradation, including reduced visibility, low contrast, and high noise
levels. Recovering ideal normal-light images from UHD low-light images is a
long-studied problem.

Figure 1: Model complexity and performance comparison between our proposed
MixNet and other LLIE methods on the UHD-LOL4K dataset. Since the inability of
most methods to process UHD images directly, the calculation of FLOPs is
performed based on the scale of 1024 $\times$ 1024 images (the maximum
resolution that these algorithms can process on a single GPU). Our MixNet
achieves a better trade-off between model complexity and performance.

Although many learning-based LLIE methods have made significant progress, they
always focus on low-resolution images Wei et al. (2018); Zhao et al. (2021);
Wu et al. (2022); Xu et al. (2022); Cai et al. (2023). For example, in the
LLIE task, the most common dataset used is LOL Wei et al. (2018), which
consists of images with resolutions below 1K ($1920\times 1080$). To achieve
better results, current state-of-the-art (SOTA) methods Hou et al. (2023); Cai
et al. (2023) commonly employ larger models and introduce a significant number
of parameters. When faced with UHD images, these SOTA methods often encounter
memory overflow and cannot perform full-resolution inference on consumer-grade
GPUs. With the prevalence of UHD images, designing a LLIE algorithm tailored
explicitly for UHD images becomes increasingly essential.

Recently, there have been some explorations into LLIE methods for UHD images
Wang et al. (2023); Li et al. (2023). LLFormer Wang et al. (2023) proposes a
transformer-based method for the UHD-LLIE task. The excellent long-range
dependency capture capability of the transformer undoubtedly brings excellent
results. However, LLFormer is also unable to perform full-resolution inference
of UHD images on consumer-grade GPUs. It requires the image to be divided into
multiple patches without overlapping for inference, and then the results are
stitched together. This process undoubtedly degrades the quality of image
restoration. UHDFour Li et al. (2023) attempts to perform LLIE in the Fourier
domain and achieves good results on the real-world dataset. To enable full-
resolution inference of UHD images on consumer-grade GPUs, FourUHD has to
downsample the processed images at high magnification ($8\times\downarrow$).
This high magnification downsampling reduces the model parameters
significantly but also leads to the loss of crucial information in the image.

In this paper, we propose a simple but effective UHD-LLIE method, called
MixNet. Specifically, we design the Feature Mixing Block which mainly contains
Global Feature Modulation Layer (GFML), Local Feature Modulation Layer (LFML),
and Feed-forward Layer (FFL). GFML is the key component of MixNet, enabling
efficient modeling of long-range dependency. The use of self-attention in
transformers endows them with powerful long-range dependency modeling
capabilities Vaswani et al. (2017). However, this approach comes with
significant computational overhead. Inspired by the vanilla MLP-Mixer
Tolstikhin et al. (2021), but different from it, GFML encodes the feature maps
of images from the perspectives of the width $W$, height $H$, and channel $C$.
Through simple dimensional transformation operations, the information encoded
in each feature map is associated and fused. It is worth noting that dimension
transformation operations do not introduce additional parameters, which means
that by permuting the feature maps from different views, GFML achieves
efficient modeling of long-range dependency. LFML is designed to capture the
local features of images. LFML adaptively calculates a set of parameters for
the redistribution of weights in the channel dimension, emphasizing the
importance of specific channels. The results of GFML and LFML are fed to FFL
which aim to transform features to a compact representation. This way, our
MixNet achieves a better trade-off between model complexity and performance.
Extensive experiments on both synthetic and real-world datasets demonstrate
that MixNet surpasses existing SOTA methods in terms of restoration quality
and generalization ability.

Our contributions can be summarized below:

  * •

We propose a simple but effective UHD-LLIE method called MixNet. MixNet can
perform full-resolution inference of UHD images on consumer-grade GPUs.
Compared to patch-based strategies, full-resolution inference can avoid the
occurrence of boundary artifacts.

  * •

We develop a novel efficient feature modulation mechanism to capture long-
range dependency, which does not need to project the input image from 3D to
2D; it maintains the spatial properties between pixels by modeling directly on
3D space.

  * •

We evaluate the proposed method quantitatively and qualitatively on synthetic
and real-world datasets, and the results show that our MixNet achieves a
favorable trade-off between accuracy and model complexity. Furthermore, MixNet
shows excellent scalability and flexibility, performing well on other image
restoration tasks (_e.g._ , dehazing).

##  2 Related Work

###  2.1 Low-Light Image Enhancement

Learning-based methods have been successfully applied to the LLIE task Fu et
al. (2022); Guo et al. (2020); Zhou et al. (2022); Wu et al. (2022); Xu et al.
(2022). RetinexNet Wei et al. (2018) relies on the Retinex theory and designs
a Decom-Net for decomposition and an Enhance-Net for illumination adjustment.
Transformers have gained significant traction in computer vision since ViT
Dosovitskiy et al. (2020) employs transformers for visual recognition tasks.
Restormer Zamir et al. (2022) efficiently achieves image restoration by
calculating self-attention at the channel dimension, thereby avoiding
significant computational overhead. It demonstrates excellent performance
across multiple tasks. Retinexformer Cai et al. (2023) introduces Retinex
theory Land (1977) to the transformer and designs an illumination-guided
transformer that utilizes illumination representations to direct the modeling
of non-local interactions of regions with different lighting conditions.
Diffusion models show realistic and detailed image generation through a
sequence of denoising refinements. PyDiff Zhou et al. (2023) introduces
diffusion models to LLIE to recover realistic details and performs sampling in
a pyramid resolution style to get a fast generation. Although the methods
above have achieved promising results in the LLIE task, they are not directly
applicable to UHD images because the additional pixels of UHD images result in
high computational overhead.

Figure 2: The overall architecture of the proposed MixiNet. MixNet first
transforms the input low-light image into the feature space using a
DownSampler, performs feature extraction using a series of Feature Mixing
Blocks (FMBs), and then reconstructs these extracted features using an
UpSampler. The FMB mainly contains a Global Feature Modulation Layer (GFML), a
Local Feature Modulation Layer (LFML), and a Feed-forward Layer (FFL).

###  2.2 UHD Image Restoration

UHD image restoration has been an emerging topic in recent years Liang et al.
(2021); Zamfir et al. (2023); Guan et al. (2022). In Zheng et al. (2021a, b),
the authors introduced bilateral learning to achieve dehazing of the UHD image
and HDR reconstruction of the UHD image. The core idea is to learn the local
affine coefficients of the bilateral grid from the low-resolution image and
apply them to the full-resolution image. UHD-SFNet Wei et al. (2022) and
FourUHD Li et al. (2023) explore underwater UHD image enhancement and UHD low-
light image enhancement in the Fourier domain. They are all inspired by the
discovery of most luminance information concentrates on amplitudes. Due to the
unavoidable need for downsampling in existing UHD image restoration methods,
NSEN Yu et al. (2023) proposes a spatial-variant and invertible nonuniform
downsampler that adaptively adjusts the sampling rate according to the
richness of details. LLFormer Wang et al. (2023) is the first transformer-
based method to complete UHD-LLIE task, but like most previous methods, it is
unable to perform full-resolution inference on consumer-grade GPUs. Despite
the promising results achieved by the aforementioned approaches, there is
still room for a favorable trade-off between reconstruction performance and
model efficiency.

##  3 Methodology

MixNet aims to recover ideal UHD normal-light images from low-light images
which often exhibit significantly reduced visibility, low contrast, and high
levels of noise. We provide the overall pipeline of our method and further
details on the critical components of our approach below.

###  3.1 Overview

An overview of MixNet is shown in Fig. 2. For a given low-light image
${x}\in\mathbb{R}^{H\times W\times 3}$, we first map it to the feature space
through a DownSampler to obtain the low-level features
${F}_{0}\in\mathbb{R}^{H\times W\times C}$, where $H$, $W$, and $C$ represent
height, width, and channel, respectively. Then, the multiple stacked Feature
Mixing Blocks (FMBs) are used to generate finer deep features ${F}_{i}$ from
${F}_{0}$ for normal-light image reconstruction, where a FMB has a Global
Feature Modulation Layer (GFML), a Local Feature Modulation Layer (LFML) and a
Feed-forward Layer (FFL). Lastly, the sum of the final features ${F}_{f}$ and
${F}_{0}$ is fed to a UpSampler to obtain the restored image ${\hat{y}}$.

Figure 3: The overall architecture of the proposed (a) Global Feature
Modulation Layer, (b) Local Feature Modulation Layer, and (c) Feed-forward
Layer. Figure 4: Visualization of dimensional transformation operations.
MixNet can capture long-range dependency of features with few parameters by
employing simple dimension transformation operations.

###  3.2 Global Feature Modulation Layer

Recent studies suggest that the notable performance of transformers across
diverse tasks stems from their implementation of the key multi-head self-
attention (MHSA) mechanism Vaswani et al. (2017). MHSA enables the model with
the capability of long-range feature interaction and dynamic spatial
weighting, both of which contribute to get promising results. However, this
mechanism comes with significant computational overhead. To capture the long-
range dependency of features, we ingeniously establish long-range
relationships in both spatial and channel dimensions by employing simple
dimension transformation operations. This allows for achieving long-range
dependency of features by only using a few parameters.

The architecture of the GFML is shown in Fig. 3 (a) and the more details of
dimension transformation operations are shown in Fig. 4. Specifically, we
first adjust the resolution of the normalized input features, and then perform
some dimension transformation operations on them. Given the input feature
$F_{in}$, this procedure can be formulated as:

$\displaystyle F_{t}$ $\displaystyle=\operatorname{IP}(F_{in}),$ (1)
$\displaystyle\hat{F}_{t}$
$\displaystyle=\underbrace{\operatorname{Permute}(\operatorname{GELU}(\operatorname{Conv_{1\times
1}}(F_{t})))}_{\times 3},$ (2)

where $F_{t}$ and $\hat{F}_{t}$ are intermediate results.
$\operatorname{IP}(\cdot)$ corresponds to the interpolation operation,
$\operatorname{Conv_{1\times 1}}(\cdot)$ is a $1\times 1$ convolution,
$\operatorname{GELU}(\cdot)$ represents GELU function,
$\operatorname{Permute}(\cdot)$ denotes the dimension transformation operation
and $\times 3$ denotes three operations in sequence. It is worth noting that
before executing the last dimension transformation operation, we replace the
GELU function with the Sigmoid function.

Afterward, We use interpolation to adjust the feature $\hat{F}_{t}$ to its
original resolution to estimate the attention map and adaptively modulate the
input $F_{in}$ according to the estimated attention via element-wise product.
This process can be written as:

$F_{g}=\operatorname{IP}(\hat{F}_{t})\odot F_{in},$ (3)

where $F_{g}$ are the final output features and $\odot$ represents element-
wise product.

###  3.3 Local Feature Modulation Layer

LFML aims to capture the local feature of images and the architecture of it is
shown in Fig. 3 (b). For a set of feature maps, their impact on the final
results is different Zhang et al. (2018b), and we hope the model can focus on
the important feature maps. We first feed the normalized input features into
global average pooling to shift the focus of the model from space dimension to
channel dimension, and then feed them into a series of convolutions to get
deep features. Finally, these deep features are processed by the sigmoid
function to obtain the weight of each channel. The normalized input features
adaptively adjust the importance of the channel based on these weights via
element-wise product. The LFML can be written as:

$\displaystyle F_{w}$
$\displaystyle=\operatorname{Sigmoid}(\operatorname{Conv}(\operatorname{ReLU}(\operatorname{Conv}(\operatorname{GAP}(F_{in}))))),$
(4) $\displaystyle F_{l}$ $\displaystyle=F_{w}\odot F_{in},$ (5)

where $F_{in}$ stand for the input features, $F_{w}$ are the channel weights
and $F_{l}$ denote the final output features. $\operatorname{Sigmoid}(\cdot)$
represents Sigmoid function, $\operatorname{Conv}(\cdot)$ is a $1\times 1$
convolution and $\operatorname{GAP}(\cdot)$ denotes global average pooling.

###  3.4 Feed-forward Layer

To transform features into a compact representation, we introduce FFL into our
model. As shown in Fig. 3 (c), FFL comprises a $3\times 3$ convolution, a
$1\times 1$ convolution, and a GELU function. Within this, the first $3\times
3$ convolution encodes the spatially local contexts and doubles the number of
channels of the input features for mixing channels; the later $1\times 1$
convolution reduces the channels back to the original input dimension. In this
way, the model learns a more compact representation of features and ignores
some unimportant information Tan and Le (2021). The FFL can be expressed as:

$F_{out}=\operatorname{Conv_{1\times
1}(\operatorname{GELU}(\operatorname{Conv}_{3\times 3}((F_{in})))))},$ (6)

where $F_{in}$ and $F_{out}$ are the input features and output features,
respectively.

###  3.5 Feature Mixing Block

Here, we describe our FMB pipeline in general, which can be written as:

$\displaystyle\hat{F}_{in}$
$\displaystyle=\operatorname{Conv}[\operatorname{GFML}(\operatorname{LN}(F_{in}));\operatorname{LFML}(\operatorname{LN}(F_{in}))]+F_{in},$
(7) $\displaystyle F_{out}$
$\displaystyle=\operatorname{FFL}(\operatorname{LN}(\hat{F}_{in}))+\hat{F}_{in},$
(8)

where $F_{in}$ stand for the input features, $\hat{F}_{in}$ are the
intermediate features and $F_{out}$ denote the output features. [;] is
concatenation operation, and $\operatorname{Conv}$ respresents the $1\times 1$
convolution.

###  3.6 Loss Functions

To optimize the weights and biases of the network, we utilize the L1 loss in
the RGB color space as the basic reconstruction loss:

$L=\|y-\hat{y}\|_{1},$ (9)

where $y$ and $\hat{y}$ denote the ground truth and restored image,
respectively.

Figure 5: Visual quality comparisons. The image can be zoomed in for better
visualization. The last row shows the color histogram of the image. Our method
has the closest color to GT image. Table 1: Comparison of quantitative results
on UHD-LOL4K and UHD-LL datasets. Best and second best values are indicated
with bold text and underlined text respectively.

Type | Methods | UHD-LOL4K | UHD-LL | Average | Parameter
---|---|---|---|---|---
PSNR | SSIM | LPIPS | PSNR | SSIM | LPIPS | PSNR | SSIM | LPIPS
non-UHD | Zero-DCE Guo et al. (2020) | 17.19 | 0.850 | 0.193 | 17.08 | 0.663 | 0.513 | 17.14 | 0.757 | 0.353 | 79.416K
Zero-DCE++ Li et al. (2021) | 15.58 | 0.835 | 0.222 | 16.41 | 0.630 | 0.530 | 16.00 | 0,733 | 0.376 | 10.561K
RUAS Liu et al. (2021) | 14.68 | 0.758 | 0.274 | 13.56 | 0.749 | 0.460 | 14.12 | 0.754 | 0.367 | 3.438K
Uformer Wang et al. (2022) | 29.99 | 0.980 | 0.034 | 19.28 | 0.849 | 0.356 | 24.64 | 0.915 | 0.195 | 20.628M
Restormer Zamir et al. (2022) | 36.91 | 0.988 | 0.023 | 22.25 | 0.871 | 0.289 | 29.58 | 0.930 | 0.156 | 26.112M
UHD | LLFormer Wang et al. (2023) | 37.33 | 0.989 | 0.020 | 22.79 | 0.853 | 0.264 | 30.06 | 0.921 | 0.142 | 13.152M
UHDFour Li et al. (2023) | 36.12 | 0.990 | 0.021 | 26.22 | 0.900 | 0.239 | 31.17 | 0.945 | 0.130 | 17.537M
MixNet | 39.22 | 0.992 | 0.006 | 27.54 | 0.862 | 0.134 | 33.38 | 0.927 | 0.070 | 7.770M

##  4 Experiment

###  4.1 Implementation Details and Datasets

####  4.1.1 Implementation Details

We conduct experiments in PyTorch on six NVIDIA GeForce RTX 3090 GPUs. To
optimize the network, we employ the Adam optimizer with a learning rate
$2\times 10^{-4}$. We randomly crop the full-resolution 4K image to a
resolution of $512\times 512$ as the input and perform 300k iterations of
training with a batch size of 24. To augment the training data, random
horizontal and vertical flips are applied to the input images. The number of
FMB and feature channels is set to 8 and 48, respectively. DownSampler and
UpSampler are both composed of a sub-pixel convolutional layer Shi et al.
(2016) and a $3\times 3$ convolutional layer.

####  4.1.2 Datasets

##### UHD-LOL.

UHD-LOL Wang et al. (2023) is a large-scale benchmark dataset containing UHD
images in low-light conditions and includes two subsets, UHD-LOL4K and UHD-
LOL8K, containing 4K and 8K-resolution images, respectively. In this paper, we
use the UHD-LOL4K to verify the effectiveness of MixNet. UHD-LOL4K contains
8,099 image pairs, 5,999 for training and 2, 100 for testing.

##### UHD-LL.

UHD-LL Li et al. (2023) is a real-world low-noise/normal-clear paired image
dataset that contains 2,150 pairs of 4K UHD data saved in 8bit sRGB format. It
has been split into two parts: 2,000 pairs for training and 115 pairs for
testing.

##### LOL.

In addition to the aforementioned UHD datasets, we also evaluate our method on
the LOL dataset Wei et al. (2018) which is the commonly used dataset in the
LLIE task. LOL has 500 image pairs and the training and testing sets are split
in proportion to 485:15.

Figure 6: Visual quality comparisons. The image can be zoomed in for improved
visualization. Our method can effectively remove the noise and reconstruct
well-exposed image details.

###  4.2 Comparisons with the State-of-the-art Methods

####  4.2.1 Quantitative Results

We employ three well-known image quality assessment metrics, PSNR, SSIM Wang
et al. (2004) and LPIPS (Alex version) Zhang et al. (2018a) to quantify the
performance of different methods. PSNR and SSIM are calculated along the RGB
channels. For UHD datasets, we compare our method with Zero-DCE Guo et al.
(2020), Zero-DCE++ Li et al. (2021), RUAS Liu et al. (2021), Uformer Wang et
al. (2022), Restormer Zamir et al. (2022), LLFormer Wang et al. (2023) and
UHDFour Li et al. (2023). It is worth noting that most methods cannot directly
perform full-resolution inference on UHD images. Therefore, for these methods,
we adopt a strategy of dividing the images into multiple patches without
overlapping for interference, and then the results are stitched together. For
the LOL dataset, in addition to the mentioned methods, we also compare our
MixNet with methods RetinexNet Wei et al. (2018), KinD Zhang et al. (2019),
DSLR Lim and Kim (2020), RUAS Liu et al. (2021), ELGAN Jiang et al. (2021) and
Retinexformer Cai et al. (2023).

In Tab. 1, we report the quantitative comparison results among different
methods on the UHD dataset. When compared with the previous SOTA method
FourUHD, our MixNet gains by an average of 2.21dB on the UHD-LOL4K and UHD-LL
datasets. Compared to other methods specifically designed for UHD images, our
MixNet achieves impressive results with few parameters. Our method also
performs well on the LOL dataset and the results are reported in Tab. 2. It is
worth noting that the resolution of LOL images is relatively low. Therefore,
we replace the sub-pixel convolutional layer in DownSampler and UpSampler with
the Residual Block of comparable parameters.

All these results clearly suggest the outstanding effectiveness and efficiency
advantage of our MixNet.

####  4.2.2 Qualitative Results

In addition to the quantitative evaluations, we also provide qualitative
comparisons of the proposed method. Figs. 5 and 6 present the visual
comparisons. MixNet can effectively enhance the poor visibility and low
contrast or low-light regions, reliably remove the noise without introducing
spots and artifacts, and robustly preserve the color.

Table 2: Comparison of quantitative results on LOL dataset. Best and second
best values are indicated with bold text and underlined text respectively.

Type | Methods | PSNR | SSIM
---|---|---|---
non-UHD | RetinexNet Wei et al. (2018) | 16.77 | 0.425
KinD Zhang et al. (2019) | 17.65 | 0.772
DSLR Lim and Kim (2020) | 14.98 | 0.596
Z_DCE Guo et al. (2020) | 14.86 | 0.562
Z_DCE++ Li et al. (2021) | 14.75 | 0.518
RUAS Liu et al. (2021) | 16.40 | 0.503
ELGAN Jiang et al. (2021) | 17.48 | 0.652
Uformer Wang et al. (2022) | 18.55 | 0.721
Restormer Zamir et al. (2022) | 22.37 | 0.816
Retinexformer Cai et al. (2023) | 25.16 | 0.845
UHD | UHDFour Li et al. (2023) | 23.09 | 0.871
LLFormer Wang et al. (2023) | 23.65 | 0.816
MixNet | 24.21 | 0.860

###  4.3 Ablation Study

We further conduct extensive ablation studies to better understand and
evaluate each component in the proposed MixNet. For fair comparisons with the
designed baselines, we implement all experiments with the same setting on UHD-
LOL4K dataset. We gradually replace the proposed module with the Residual
Block (ResBlock) He et al. (2016) of comparable parameters, and the
experimental results in Tab. 4.

Based on all the results in the Tab. 4, all the key designs contribute to the
best performance of the full model. Without the GFML (#a, #c, #d, #f), the
model shows the most severe performance degradation. This aligns with our
hypothesis, as the excellent long-range dependency modeling capability brought
by GMFL is one of the key factors contributing to the outstanding performance
of MixNet. And the result suggests the importance of long-range dependency
modeling among features. From the results of #g and #e, we find that the
impact of FFL on performance is higher than that of GFML. We believe that this
might be the ability of the FFL to learn compact feature representations,
which the ResBlock lacks. And any CNN is capable of learning local features.
From the results of #c and #d, we observe that when using the block we
proposed alone, LFML has a higher impact on the results than FFL. This may be
because when the feature representation is not effective enough (not from GFML
and LFML), learning its compact representation has little effect. We also
provide visualizations of the feature maps corresponding to #e, #f, #g and #h.
As shown in Fig. 7, it is evident that our method reconstructs feature maps
with sharper textures.

Table 3: Comparison of quantitative results on O-Haze dataset. Best and second
best values are indicated with bold text and underlined text respectively.

Task | Methods | PSNR | SSIM
---|---|---|---
non-UHD | DCP He et al. (2010) | 14.54 | 0.333
BCCR Meng et al. (2013) | 15.20 | 0.361
CAP Zhu et al. (2015) | 15.35 | 0.342
NLD Berman et al. (2016) | 14.76 | 0.396
DehazeNet Cai et al. (2016) | 12.39 | 0.359
AodNet Li et al. (2017) | 15.87 | 0.581
GridNet Liu et al. (2019) | 17.44 | 0.603
PMSNet Chen et al. (2019) | 16.99 | 0.597
MSBDN Dong et al. (2020) | 17.46 | 0.635
UHD | MGBL Zheng et al. (2021a) | 18.72 | 0.614
NSEN Yu et al. (2023) | 19.23 | 0.672
MixNet | 21.46 | 0.650

###  4.4 Extension Experiments

Although we primarily focus on the UHD-LLIE task in this paper, it is
important to note that we do not introduce specific prior knowledge related to
low-light conditions. Therefore, our method can be considered as a general
approach that performs well not only in UHD-LLIE task but also in various UHD
image restoration task, such dehazing.

####  4.4.1 Datasets

We conduct dehazing experiments on the O-HAZE dataset which has 45 paired hazy
and haze-free images. Following the prior work Yu et al. (2023), we randomly
choose 35 images for training and the others for testing.

####  4.4.2 Results

We compare the proposed MixNet with several image dehazing approaches Berman
et al. (2016); He et al. (2010); Meng et al. (2013); Zhu et al. (2015); Li et
al. (2017); Dong et al. (2020); Liu et al. (2019); Cai et al. (2016); Chen et
al. (2019); Zheng et al. (2021a); Yu et al. (2023). Results are reported in
Tab. 3. MixNet achieves a substantial gain of over 2 dB compared to NSEN in
PSNR on the UHD image dehazing task.

Table 4: Ablation study of proposed blocks. In order to ensure consistency in
parameter magnitude, we gradually replace the proposed module with Residual
Block of comparable parameters.

# | GFML | LFML | FFL | PSNR | SSIM | Parameter
---|---|---|---|---|---|---
(a) |  |  |  | 30.73 | 0.968 | 7.178M
(b) | ✓ |  |  | 34.16 | 0.985 | 7.475M
(c) |  | ✓ |  | 33.93 | 0.984 | 6.882M
(d) |  |  | ✓ | 32.52 | 0.976 | 7.769M
(e) | ✓ |  | ✓ | 36.44 | 0.990 | 8.066M
(f) |  | ✓ | ✓ | 34.47 | 0.987 | 7.474M
(g) | ✓ | ✓ |  | 35.80 | 0.988 | 7.179M
(h) | ✓ | ✓ | ✓ | 39.22 | 0.992 | 7.770M

Figure 7: Visualizations of the feature maps before the UpSampler. The image
used here is the low-light image shown in Fig. 6. Our method reconstructs
feature maps with sharper textures.

##  5 Conclusion

In this paper, we proposed a simple yet efficient framework called MixNet to
solve the efficient UHD-LLIE problem. MixNet has a series of FMBs which mainly
contain a GFML, LFML, and FFL. GFML explored long-range dependency modeling
upon the simple dimensional transformation operation. By permuting the feature
maps, GFML associates features from different views. LFML and FFL are designed
to capture local features and transform features into a compact
representation, respectively. Extensive experiments on both synthetic and
real-world datasets showed that the proposed MixNet is more efficient than
state-of-the-art methods while achieving competitive performance.

## References

  * Berman et al. [2016] Dana Berman, Shai Avidan, et al.  Non-local image dehazing.  In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 1674–1682, 2016.
  * Cai et al. [2016] Bolun Cai, Xiangmin Xu, Kui Jia, Chunmei Qing, and Dacheng Tao.  Dehazenet: An end-to-end system for single image haze removal.  IEEE transactions on image processing, 25(11):5187–5198, 2016.
  * Cai et al. [2023] Yuanhao Cai, Hao Bian, Jing Lin, Haoqian Wang, Radu Timofte, and Yulun Zhang.  Retinexformer: One-stage retinex-based transformer for low-light image enhancement.  arXiv preprint arXiv:2303.06705, 2023.
  * Chen et al. [2019] Wei-Ting Chen, Jian-Jiun Ding, and Sy-Yen Kuo.  Pms-net: Robust haze removal based on patch map for single images.  In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 11681–11689, 2019.
  * Dong et al. [2020] Hang Dong, Jinshan Pan, Lei Xiang, Zhe Hu, Xinyi Zhang, Fei Wang, and Ming-Hsuan Yang.  Multi-scale boosted dehazing network with dense feature fusion.  In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 2157–2167, 2020.
  * Dosovitskiy et al. [2020] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, et al.  An image is worth 16x16 words: Transformers for image recognition at scale.  arXiv preprint arXiv:2010.11929, 2020.
  * Fu et al. [2022] Ying Fu, Yang Hong, Linwei Chen, and Shaodi You.  Le-gan: Unsupervised low-light image enhancement network using attention module and identity invariant loss.  Knowledge-Based Systems, 240:108010, 2022.
  * Guan et al. [2022] Juntao Guan, Rui Lai, Yang Lu, Yangang Li, Huanan Li, Lichen Feng, Yintang Yang, and Lin Gu.  Memory-efficient deformable convolution based joint denoising and demosaicing for uhd images.  IEEE Transactions on Circuits and Systems for Video Technology, 32(11):7346–7358, 2022.
  * Guo et al. [2020] Chunle Guo, Chongyi Li, Jichang Guo, Chen Change Loy, Junhui Hou, Sam Kwong, and Runmin Cong.  Zero-reference deep curve estimation for low-light image enhancement.  In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 1780–1789, 2020.
  * He et al. [2010] Kaiming He, Jian Sun, and Xiaoou Tang.  Single image haze removal using dark channel prior.  IEEE transactions on pattern analysis and machine intelligence, 33(12):2341–2353, 2010.
  * He et al. [2016] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun.  Deep residual learning for image recognition.  In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 770–778, 2016.
  * Hou et al. [2023] Jinhui Hou, Zhiyu Zhu, Junhui Hou, Hui Liu, Huanqiang Zeng, and Hui Yuan.  Global structure-aware diffusion process for low-light image enhancement.  arXiv preprint arXiv:2310.17577, 2023.
  * Jiang et al. [2021] Yifan Jiang, Xinyu Gong, Ding Liu, Yu Cheng, Chen Fang, Xiaohui Shen, Jianchao Yang, Pan Zhou, and Zhangyang Wang.  Enlightengan: Deep light enhancement without paired supervision.  IEEE transactions on image processing, 30:2340–2349, 2021.
  * Land [1977] Edwin H Land.  The retinex theory of color vision.  Scientific american, 237(6):108–129, 1977.
  * Li et al. [2017] Boyi Li, Xiulian Peng, Zhangyang Wang, Jizheng Xu, and Dan Feng.  Aod-net: All-in-one dehazing network.  In Proceedings of the IEEE international conference on computer vision, pages 4770–4778, 2017.
  * Li et al. [2021] Chongyi Li, Chunle Guo, and Chen Change Loy.  Learning to enhance low-light image via zero-reference deep curve estimation.  IEEE Transactions on Pattern Analysis and Machine Intelligence, 44(8):4225–4238, 2021.
  * Li et al. [2023] Chongyi Li, Chun-Le Guo, Man Zhou, Zhexin Liang, Shangchen Zhou, Ruicheng Feng, and Chen Change Loy.  Embedding fourier for ultra-high-definition low-light image enhancement.  arXiv preprint arXiv:2302.11831, 2023.
  * Liang et al. [2021] Jie Liang, Hui Zeng, and Lei Zhang.  High-resolution photorealistic image translation in real-time: A laplacian pyramid translation network.  In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 9392–9400, 2021.
  * Lim and Kim [2020] Seokjae Lim and Wonjun Kim.  Dslr: Deep stacked laplacian restorer for low-light image enhancement.  IEEE Transactions on Multimedia, 23:4272–4284, 2020.
  * Liu et al. [2019] Xiaohong Liu, Yongrui Ma, Zhihao Shi, and Jun Chen.  Griddehazenet: Attention-based multi-scale network for image dehazing.  In Proceedings of the IEEE/CVF international conference on computer vision, pages 7314–7323, 2019.
  * Liu et al. [2021] Risheng Liu, Long Ma, Jiaao Zhang, Xin Fan, and Zhongxuan Luo.  Retinex-inspired unrolling with cooperative prior architecture search for low-light image enhancement.  In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10561–10570, 2021.
  * Meng et al. [2013] Gaofeng Meng, Ying Wang, Jiangyong Duan, Shiming Xiang, and Chunhong Pan.  Efficient image dehazing with boundary constraint and contextual regularization.  In Proceedings of the IEEE international conference on computer vision, pages 617–624, 2013.
  * Shi et al. [2016] Wenzhe Shi, Jose Caballero, Ferenc Huszár, Johannes Totz, Andrew P Aitken, Rob Bishop, Daniel Rueckert, and Zehan Wang.  Real-time single image and video super-resolution using an efficient sub-pixel convolutional neural network.  In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 1874–1883, 2016.
  * Tan and Le [2021] Mingxing Tan and Quoc Le.  Efficientnetv2: Smaller models and faster training.  In International conference on machine learning, pages 10096–10106. PMLR, 2021.
  * Tolstikhin et al. [2021] Ilya O Tolstikhin, Neil Houlsby, Alexander Kolesnikov, Lucas Beyer, Xiaohua Zhai, Thomas Unterthiner, Jessica Yung, Andreas Steiner, Daniel Keysers, Jakob Uszkoreit, et al.  Mlp-mixer: An all-mlp architecture for vision.  Advances in neural information processing systems, 34:24261–24272, 2021.
  * Vaswani et al. [2017] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin.  Attention is all you need.  Advances in neural information processing systems, 30, 2017.
  * Wang et al. [2004] Zhou Wang, Alan C Bovik, Hamid R Sheikh, and Eero P Simoncelli.  Image quality assessment: from error visibility to structural similarity.  IEEE transactions on image processing, 13(4):600–612, 2004.
  * Wang et al. [2022] Zhendong Wang, Xiaodong Cun, Jianmin Bao, Wengang Zhou, Jianzhuang Liu, and Houqiang Li.  Uformer: A general u-shaped transformer for image restoration.  In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 17683–17693, 2022.
  * Wang et al. [2023] Tao Wang, Kaihao Zhang, Tianrun Shen, Wenhan Luo, Bjorn Stenger, and Tong Lu.  Ultra-high-definition low-light image enhancement: A benchmark and transformer-based method.  In Proceedings of the AAAI Conference on Artificial Intelligence, volume 37, pages 2654–2662, 2023.
  * Wei et al. [2018] Chen Wei, Wenjing Wang, Wenhan Yang, and Jiaying Liu.  Deep retinex decomposition for low-light enhancement.  arXiv preprint arXiv:1808.04560, 2018.
  * Wei et al. [2022] Yiwen Wei, Zhuoran Zheng, and Xiuyi Jia.  Uhd underwater image enhancement via frequency-spatial domain aware network.  In Proceedings of the Asian Conference on Computer Vision, pages 299–314, 2022.
  * Wu et al. [2022] Wenhui Wu, Jian Weng, Pingping Zhang, Xu Wang, Wenhan Yang, and Jianmin Jiang.  Uretinex-net: Retinex-based deep unfolding network for low-light image enhancement.  In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 5901–5910, 2022.
  * Xu et al. [2022] Xiaogang Xu, Ruixing Wang, Chi-Wing Fu, and Jiaya Jia.  Snr-aware low-light image enhancement.  In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 17714–17724, 2022.
  * Yu et al. [2023] Wei Yu, Qi Zhu, Naishan Zheng, Jie Huang, Man Zhou, and Feng Zhao.  Learning non-uniform-sampling for ultra-high-definition image enhancement.  In Proceedings of the 31st ACM International Conference on Multimedia, pages 1412–1421, 2023.
  * Zamfir et al. [2023] Eduard Zamfir, Marcos V Conde, and Radu Timofte.  Towards real-time 4k image super-resolution.  In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 1522–1532, 2023.
  * Zamir et al. [2022] Syed Waqas Zamir, Aditya Arora, Salman Khan, Munawar Hayat, Fahad Shahbaz Khan, and Ming-Hsuan Yang.  Restormer: Efficient transformer for high-resolution image restoration.  In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 5728–5739, 2022.
  * Zhang et al. [2018a] Richard Zhang, Phillip Isola, Alexei A Efros, Eli Shechtman, and Oliver Wang.  The unreasonable effectiveness of deep features as a perceptual metric.  In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 586–595, 2018.
  * Zhang et al. [2018b] Yulun Zhang, Kunpeng Li, Kai Li, Lichen Wang, Bineng Zhong, and Yun Fu.  Image super-resolution using very deep residual channel attention networks.  In Proceedings of the European conference on computer vision (ECCV), pages 286–301, 2018.
  * Zhang et al. [2019] Yonghua Zhang, Jiawan Zhang, and Xiaojie Guo.  Kindling the darkness: A practical low-light image enhancer.  In Proceedings of the 27th ACM international conference on multimedia, pages 1632–1640, 2019.
  * Zhao et al. [2021] Lin Zhao, Shao-Ping Lu, Tao Chen, Zhenglu Yang, and Ariel Shamir.  Deep symmetric network for underexposed image enhancement with recurrent attentional learning.  In Proceedings of the IEEE/CVF international conference on computer vision, pages 12075–12084, 2021.
  * Zheng et al. [2021a] Zhuoran Zheng, Wenqi Ren, Xiaochun Cao, Xiaobin Hu, Tao Wang, Fenglong Song, and Xiuyi Jia.  Ultra-high-definition image dehazing via multi-guided bilateral learning.  In 2021 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 16180–16189. IEEE, 2021.
  * Zheng et al. [2021b] Zhuoran Zheng, Wenqi Ren, Xiaochun Cao, Tao Wang, and Xiuyi Jia.  Ultra-high-definition image hdr reconstruction via collaborative bilateral learning.  In Proceedings of the IEEE/CVF international conference on computer vision, pages 4449–4458, 2021.
  * Zhou et al. [2022] Shangchen Zhou, Chongyi Li, and Chen Change Loy.  Lednet: Joint low-light enhancement and deblurring in the dark.  In European Conference on Computer Vision, pages 573–589. Springer, 2022.
  * Zhou et al. [2023] Dewei Zhou, Zongxin Yang, and Yi Yang.  Pyramid diffusion models for low-light image enhancement.  arXiv preprint arXiv:2305.10028, 2023.
  * Zhu et al. [2015] Qingsong Zhu, Jiaming Mai, and Ling Shao.  A fast single image haze removal algorithm using color attenuation prior.  IEEE transactions on image processing, 24(11):3522–3533, 2015.


#  : A MCMC Inference tool for Physical Parameters of Molecular Clouds

Marcus Keil  Univsersity College London, Gower St, Bloomsbury, London WC1E
6BT, England  Serena Viti  Leiden Observatory, Leiden University, P.O. Box
9513, 2300 RA Leiden, The Netherlands  Univsersity College London, Gower St,
Bloomsbury, London WC1E 6BT, England  Jonathan Holdship  Leiden Observatory,
Leiden University, P.O. Box 9513, 2300 RA Leiden, The Netherlands  Univsersity
College London, Gower St, Bloomsbury, London WC1E 6BT, England

(Accepted 02.02.2022)

###### Abstract

We present the publicly available, open source code , designed to estimate
physical parameters of an observed cloud of gas by combining Monte Carlo
Markov Chain (MCMC) sampling with chemical and radiative transfer modeling.
When given the observed values of different emission lines, runs a Bayesian
parameter inference, using a MCMC algorithm to sample the likelihood and
produce an estimate of the posterior probability distribution of the
parameters. takes a full forward modeling approach, generating model
observables from the physical parameters via chemical and radiative transfer
modeling. While running , the created chemical models and radiative transfer
code results are stored in an SQL database, preventing redundant model
calculations in future inferences. This means that the more is used, the more
efficient it becomes. Using UCLCHEM and RADEX, the increase of efficiency is
nearly two orders of magnitude, going from $5185.33\pm 1041.96\,\mathrm{s}$
for ten walkers to take one thousand steps when the database is empty, to
$68.89\pm 45.39\,\mathrm{s}$ when nearly all models requested are in the
database. In order to demonstrate its usefulness we provide an example
inference of to estimate the physical parameters of mock data, and perform two
inferences on the well studied prestellar core, L1544, one of which show that
it is important to consider the substructures of an object when determining
which emission lines to use.

astrochemistry — ISM: molecules

††journal: ApJ

##  1 Introduction

Throughout the interstellar medium (ISM), chemical reactions impact the
environments that we observe. In turn, the physics of a molecular cloud
greatly affects the chemistry. For example, at high densities
($\gtrapprox\,10^{5}\,\mathrm{cm}^{-3}$ ) and low temperatures
($\lessapprox\,30\,\mathrm{K}$), atoms and molecules freeze out onto dust
grains where they can react through many pathways (for a review see Allodi et
al. (2013)). On the other hand shocks from protostellar outflows impacting the
surrounding medium can lead to desorption of many molecular species stored on
dust grains (Caselli et al., 1997). Hence, emission and absorption lines of
different species allow us to study the physics of the objects we observe.

In order to interpret the observations that are made, radiative transfer codes
can be used to calculate the expected intensities that should be observed with
a given set of physical parameters. One example of such a code is RADEX (van
der Tak et al., 2007) which focuses on non-LTE analysis. These types of codes
require parameters that describe the condition of the gas as well as the
column density of a species. These are connected by chemistry but treated as
free parameters in many radiative transfer models. Modeling tools such as
UCLCHEM (Holdship et al., 2017) or GRAINOBLE (Taquet et al., 2012) amongst
many others, provide the fractional abundances of species which can be used to
calculate the column density. The fractional abundances can be combined with
estimates of the total gas column density of an object in order to calculate
the column density of an individual species.

Figure 1: Flow Chart of the various processes that happen in . Green ovals
indicate parts that the User interfaces with. Diamonds indicate parts of where
the next step is dependent on options the user specifies. The SQL Database is
represented with a cylinder and has been labeled this way for clarity. Arrows
to and from the database represent a query of the SQL which then returns the
models that match the query.

Chemical models calculate fractional abundances by considering the rate of
change of many species as the interact through a network of reactions. These
reaction networks usually include a gas phase database such as KIDA (Wakelam
et al., 2012) or UMIST (McElroy, D. et al., 2013), as well as gas-grain and
grain surface processes such as freeze out, non thermal desorption and surface
reactions. Additional processes such as thermal desorption or sputtering of
ice mantles are often included depending on the chemical code and its intended
purpose. The complexity involved in determining what should be included in
these models in order to maximise the accuracy while minimising computational
cost of creating a model, is an aspect that requires significant expertise.

The best modeling approaches combine the chemical modeling codes with the
radiative transfer codes. One benefit in doing this is that the column
densities can be calculated with the chemical model which can then be combined
with the set of physical parameters calculated by the chemical code to use as
parameters for the radiative transfer model. There are additional parameters
for the radiative transfer codes, such as line width, which are not directly
calculated by a chemical code but can be treated as free parameters or derived
from observations. The outputs from the radiative transfer code can then be
compared to spectroscopic observations (Harada et al., 2019; Punanova et al.,
2018; Viti, 2017).

In order to assist in the inference of physical parameters of an observation,
we present the open-source, MCMC inference tool
111https://zenodo.org/badge/latestdoi/334982976. The intended use of is to
infer the probability distribution of key physical parameters given some
observed data. The following section will describe the code in detail,
starting with the forward modeling approach and what tools it uses in section
2.1, followed by the work flow of the code and how it stores models to allow
future inferences to be more efficient in section 2.3 followed by a brief
description of the chosen interface in section 2.4. After that, we will
examine an example case by providing with mock observations, and then perform
a stress test inference using observations of the prestellar core L1544 in
section 3, before going on to discuss caveats for the use of this tool and
summarising in section 4.

##  2

Table 1: Inputs and options per page

Page | Input/Option | Description
---|---|---
Parameter input (Page 1) | Final volume Density [cm3] | Hydrogen volume density at which the model stops collapsing
| Kinetic temperature [K] | Kinetic temperature of the gas
| Cosmic ray ionisation rate |  Multiplicative factor of the galactic rate of ionisation caused by Cosmic rays ($1.3\times 10^{-17}\,\mathrm{s}^{-1}$)
| UV radiation field strength |  Strength of the external UV radiation field strength acting on the cloud
| Rout [pc] | Radius of the modelled cloud
| Line width [$\mathrm{km\,s}^{-1}$] | RADEX Line width of observation
Observation input (Page 2) | Species list | List of the species that have been configured
| Transition list |  List of transition lines that have been configured for a given species
| Observation inputs |  Space to fill in the observations, errors and choice of units for the observation
Options (Page 3) | Grid type |  Choice on whether to use coarse or fine grid for the parameters being inferred
| Informed starting position |  Choice on whether to use informed starting positions or random starting positions
| Session name |  Back-end session name to allow the session to be reloaded later
| Number of walker |  Number of walkers the MCMC should use (It is recommended by the package emcee to use twice as many walkers as parameters being inferred)
| Number of steps |  choice of the number of steps an inference should take before stopping and loading evaluation corner plots
Inference (Page 4) | Start inference |  to start the MCMC inference or continue it if a previous session is loaded
| MCMC corner plot |  MCMC corner plots of previous steps, if previous steps exist, or the starting positions if a new inference is being started

Note. — Options of inputs and outputs per page for

Figure 2: Small flow chart showing which parameters go into UCLCHEM and which
parameters are taken from UCLCHEM and given to RADEX.

infers physical parameter values from molecular observations using chemical
and radiative transfer models. First, we use a chemical model, in order to
obtain abundances for a user-defined list of species has been configured for.
These abundances, can then be used with a radiative transfer model, to
calculate the intensities for the emission lines of those species. For a
single model, this process can take several minutes to be calculated on a
standard computer.

In order to infer the physical parameter values, we use the affine-invariant
Markov Chain Monte Carlo (MCMC) Ensemble algorithm of Goodman & Weare (2010)
as implemented in the python package emcee (Foreman-Mackey et al., 2013). This
kind of sampling initiates walkers with a set of physical parameters which are
used to calculate the chemical and radiative transfer models as just
described. During each step, the walkers calculate the likelihood value for
that set of parameters using the likelihood function given by the user (see
section 2.2 for the details on the likelihood). After calculating the
likelihood of the current values, the walkers choose a new set of values in
parameter space, for which the likelihood is also evaluated. At this point,
the walker must decide if it will remain stationary for this step, discarding
the new set of values and keeping the one it already has, or if it will
discard the old values and keep the new ones. This decision is dependent on
the type of ”move” function that is chosen (for details, please refer to
Foreman-Mackey et al. (2013)). The default function for is a combination of a
differential evolution proposal (Nelson et al., 2013) and a snooker proposal
using differential evolution (ter Braak & Vrugt, 2008). Mixing like this is
recommended by Foreman-Mackey et al. (2013) when dealing with multi-modal
problems as the differential evolution proposal can allow for large enough
step sizes to cross between peaks in probability. However, the standard
version strongly recommends that at least $N=2d$ walkers are used, where $d$
is the number of parameters over which to infer, and performs better with
higher $N$. The snooker proposal using differential evolution allows for
improved performance, compared to the basic version, when a smaller number of
walkers is used. The process of sampling parameter space in this way requires
thousands of models to be calculated before a meaningful posterior is
produced. The calculations of each model using UCLCHEM and RADEX can take a
minute or more, which can result in several hours of computing time prior to
the parameter space being sampled enough to produce a usable posterior.

Our aim is to improve the efficiency without decreasing the accuracy. To do
this manages a database of previously calculated models from which it can
retrieve values when required. The curated database contains the input and
output from both the chemical and radiative transfer models, and is used to
perform an inference of the physical parameter space of an observed object
without repeating any calculation. Anytime a new step is taken, it can check
if this combination of parameters has been used before, and if it has, use the
old output rather than perform a new calculation. A full flowchart of the
processes done can be found in Figure 1. In this section we will start by
briefly describing the forward modeling method we use and the software
requires in order to create the models that it stores, followed by the details
of the MCMC inference and how manages the database, before detailing the
interface it has.

###  2.1 Forward modeling

To create the simulations that are stored in the database, we use UCLCHEM
combined with RADEX as the chemical model and radiative transfer code
respectively. Physical parameters describing the gas conditions are passed to
UCLCHEM to generate abundances and then a subset of these values are passed to
RADEX in order to get a list of transition lines. Beyond the outputs from
UCLCHEM, additional free parameters are required for RADEX such as the line
width. A detailed flow chart on how the modeling tools interact with each
other can be found in Figure 2, for clarity. The inputs for UCLCHEM and RADEX,
listed in the flow chart, can be changed according to the needs of the
inference to be run, but requires changes to be made to configuration files.

By default, is configured to use RADEX for the radiative transfer
calculations; we use the fractional abundance, calculated by UCLCHEM, to
approximate the column density by using the visual extinction calculated from
the given $\mathrm{R}_{\mathrm{out}}$ and gas volume density. This value is
used along side the other inputs UCLCHEM was given, that RADEX needs as well,
such as gas volume density and kinetic temperature, in order to run the
radiative transfer model to produce observables which can be compared to the
data. The observable values RADEX produces are: radiation peak temperature
($\mathrm{T}_{\mathrm{R}}$) in K which is comparable to the measured line
intensity; integrated surface brightness in $\mathrm{K\,km}\,\mathrm{s}^{-1}$;
the isotopic flux emitted in all directions in
$\mathrm{ergs}\,(\mathrm{s\,cm}^{2})^{-1}$ (van der Tak et al., 2007). Any of
these can be sent to the likelihood function depending on the user’s data.

Both UCLCHEM and RADEX can be replaced, as is only designed to perform an MCMC
inference and manage an SQL database. As long as inputs and outputs are
carefully tailored to a given project, the code could be simply modified to be
used with any chemical modeling or radiative transfer codes. To begin, we use
a limited list of chemical species whose collisional data is available in the
Leiden Atomic and Molecular Database (LAMDA Schöier et al. (2005)), as RADEX
requires such data.

###  2.2 MCMC Inference

For the MCMC inference, uses the python package emcee (Foreman-Mackey et al.,
2013) in order to calculate the posterior probability density function (PDF)
of the physical parameters for the desired observation. We assume the errors
on the data are Gaussian and that our model provides the true intensities for
any given parameters. The initially configured likelihood of observing our
data given some parameters that was used for the example cases in section 3 is
therefore,

$\mathcal{L}(\mathrm{d}|\,\theta)=\exp\left[-\frac{1}{2}\sum_{i}\frac{(\mathrm{d}_{i}-\theta_{i})^{2}}{\sigma_{\mathrm{d}_{i}}^{2}}\right],$
(1)

where $\mathrm{d}_{i}$ represents the observed input, $\theta_{i}$ the output
from RADEX, using physical parameters from UCLCHEM, and
$\sigma_{\mathrm{d}_{i}}$ is the error in the observed input, each for line
$i$. This is then combined with a prior on the physical parameters,
$\mathrm{P}(\theta)$ and the Bayesian evidence, $\mathrm{P}(\mathrm{d})$, in
Bayes theorem to get the full PDF in the form of

$\mathrm{P}(\theta|\,\mathrm{d})=\frac{\mathrm{P}(\theta)\,\mathcal{L}(\mathrm{d}|\,\theta)}{\mathrm{P}(\mathrm{d})}.$
(2)

By default, the prior is a uniform top hat function in grid space, on the
ranges designated by the end user but can be altered by end users. As the
prior is applied in grid space, it will be a log uniform prior if the physical
parameter has a log spaced grid applied to it. The evidence is treated as a
normalisation factor, and the values that are used for our example application
on prestellar core will be discussed in section 3. This approach to parameter
inference has been used before (Holdship et al., 2019) and UCLCHEMCMC makes
such inference problems simple.

###  2.3 Database

The core of is the managing of a database of models and running an MCMC
inference which is supplemented by that database. After giving the inputs,
which will be detailed in section 2.4, initiates a string of operations in
order to start calculating the posterior PDF of the physical parameter values
of an object using an MCMC sampler. A detailed flow chart of the processes can
be seen in Figure 1. The code starts by initiating the walkers that will be
used for the MCMC inference. If informed starting positions were requested,
the SQL database will be searched for models which are similar to the given
observations based on a simple top-hat function with a configurable distance
on either side of the observed intensities. By searching and retrieving the
parameters of models that have intensities similar to the given observation,
we can construct a function by calculating the mean and standard deviation for
each parameter to produce a normal distribution from which we can sample
starting positions. Each parameter will have its own distribution from which
the starting positions for the MCMC walkers are sampled. If random starting
positions are chosen, then a uniform distribution of the parameter space is
sampled in order to create the starting positions for each walker. Upon
creating the starting positions, we then invoke the MCMC inference which will
need to be able to access the SQL database as described in section 2.3.

For the sake of storing the inputs and outputs from UCLCHEM and RADEX, we use
an SQL database using the SQLite implementation. This is chosen as it is a
light weight, widely used, and easy to implement solution for storing large
volumes of data in such a way that it can easily be queried. The main
advantage of having access to an SQL search method is that it can quickly
check if the combination of parameters to be calculated has been previously
stored. If it has, then the program goes directly to evaluating the likelihood
using equation 1, which takes an almost negligible amount of time to perform.
If the combination of parameters is not in the database, then a model can be
created and stored for that set of parameters. This means that the calculation
speed of the MCMC inference is dependent not only on the number of walkers and
desired steps, but also on how many models are stored in the database.

Based on that, will become faster as more inferences are performed. The
calculation of a single model can take around one minute when using UCLCHEM
and RADEX. While this can be parallelised, it is still a limiting factor when
thousands of models have to be calculated to get a reasonable estimation of a
PDF. On the contrary, the action of submitting a query to an SQL database and
evaluating the probability of the stored models matching the observations
takes less than a second. Improving efficiency this way has the advantage over
techniques such as emulation (de Mijolla, D. et al., 2019) as no approximation
is made. To quantify the improvement, we measure the time it took ten walkers,
to perform one hundred steps, at three different times: (i) When no database
is being used; (ii) When around half of the models the inference wants to use
are retrieved from the database; (iii) When nearly all models the inference is
using are retrieved from the database. We use this type of measurement for the
performance, as the minimum time, the time when every model can be retrieved
from the database, should be identical irrespective of the chemical and
radiative transfer model that is used. For the three cases, the mean time and
standard deviation are: (i) $5185.33\,\mathrm{s}\pm 1041.96\,\mathrm{s}$; (ii)
$4834.67\,\mathrm{s}\pm 843.24\,\mathrm{s}$; (iii) $68.89\,\mathrm{s}\pm
45.39\,\mathrm{s}$. We emphasise that the times found for case (i) and (ii)
are strongly dependent on the chemical and radiative transfer models that are
used, while case (iii) should only be weakly dependent on which models are
used, with the dependency disappearing if all models the inference wants to
use are within the database.

The database can be accessed both by the code, and by a user who wishes to use
the models stored within it for other purposes. At the time of the first
release, we store all inputs that are given to the chemical model when it is
run, as well as all outputs that are produced by it. This can include the
output of intermediate time steps which UCLCHEMCMC can be set up to store if
requested. then takes the given line width, either as a free parameter of the
MCMC or as a constant value given by the user, as well as the kinetic
temperature, volume density of H2, and the fractional abundances of the atomic
or molecular species from the chemical code in order to run the radiative
transfer code. The outputs from this code are then stored in the SQL database.
From here, the emission lines given by the radiative transfer code can be
compared to the observations to evaluate the likelihood as discussed
previously.

###  2.4 Interface

The User Interface (UI) for is browser based, in order to give a simple usable
interface that should be compatible with most operating systems. A further
advantage of this is that an online, publicly available version can be more
easily created in the future such that end users will not need to change the
workflow.

The inputs that are requested from a user of are separated onto three pages
within the UI. The first page requests the ranges of the physical parameters
over which the inference should be performed. At the time of the first
release, the configured parameters are: (i) the volume density of the gas in
cm-3 at which point the model should stop collapsing; (ii) the kinetic
temperature of the gas in K; (iii) the cosmic ray (CR) ionisation rate in
units of the galactic CR ionisation rate ($\zeta_{0}$); (iv) UV radiation
field strength in units of Habing; (v) the radius of the assumed spherical
cloud being modelled in parsec (Rout); (vi) the line width to be used with
RADEX in units of $\mathrm{km\,s}^{-1}$. Upon supplying the desired ranges and
which parameters should be kept constant, the next set of inputs is the
observations. Here, a list of species can be selected to be added to the
current inference. Once a species has been selected, the compatible lines will
be shown and can be selected, after which it is possible to add the values of
the observations, errors and the observed quantity. As of the first release,
is configured to allow for the units that RADEX has as outputs, detailed in
section 2.1.

The penultimate page contains the options for the MCMC inference. The options
are: the MCMC details, walker starting positions, and grid type. There are
three options for the MCMC algorithm that an end user can easily change and
they are: (i) the number of walkers that the inference should have; (ii) the
number of steps the inference should perform before saving; (iii) the name of
the session. Naming the session allows for an inference to be started again at
a later time without having to re-enter all the previous parameters and
observations. This was added, in case the code crashes, or if after evaluating
the results it was determined that the MCMC walkers could benefit from more
steps to ensure the walkers converged. The starting positions of the MCMC
walkers can either be randomly determined or set to inform starting positions
depending on the end users preference. The details of how informed starting
positions are calculated are given in section 2.3. The grid type option allows
an end user to choose which physical parameter space grid they want to use for
the inference they are going to run, and are intended to be created and
managed by the end user. By default, there is a coarse and fine grid provided
to give an example of how they are meant to be created. The discretisation of
the parameter space to grids was implemented as chemical models with physical
parameters that differ only to a small degree would produce nearly
indistinguishable outputs but would be considered separate models by the code
that retrieves and stores models in the SQL database. This would lead to
models with minor differences in parameters space being calculated despite
producing indistinguishable outputs.

##  3 Application

Table 2: Parameter Ranges

Parameter [Units] | Lower Bound | Upper Bound
---|---|---
Volume Density [cm-3] | $5.0\times 10^{4}$ | $1.0\times 10^{7}$
Kinetic Temperature [K] | $5$ | $20$
UV radiation field [Habing] | $0.1$ | $10$
Rout [pc] | $0.0001$ | $0.1$
CR ionisation rate [$1.3\times 10^{-17}\mathrm{s}^{-1}$] | $0.1$ | $10$

Note. — Physical Parameter range the inference is allowed to explore for both
the mock and observational inference.

Table 3: Mock Data used for Evaluation

Species | Transition | Frequency [GHz] | Line width [$km\,s^{-1}$] | RADEX Value | Mock Data (TMB) | Units
---|---|---|---|---|---|---
CS | 2,0 - 1,0 | 97.98095 | 1.0 | 2790.9 | $2412.4\pm 558.2$ | mK
SO | 2,2 - 1,1 | 86.09395 | 1.0 | 1918.6 | $2553.0\pm 383.7$ | mK
| 2,3 - 1,2 | 99.29987 | 1.0 | 450.3 | $367.6\pm 90.0$ | mK
| 3,1 - 2,1 | 109.2522 | 1.0 | 185.5 | $222.3\pm 37.1$ | mK
o-H2CS | $3_{1,3}-2_{1,2}$ | 101.4778 | 1.0 | 130.6 | $151.6\pm 26.1$ | mK
| $3_{1,2}-2_{1,1}$ | 104.6170 | 1.0 | 85.5 | $83.8\pm 17$ | mK

Note. — Values of the mock data created for evaluation of  using UCLCHEM and
RADEX. The RADEX Value column contains the value given by RADEX, while the
Mock Data column contains the same values with added Gaussian noise, and
corresponding error values.

Table 4: Observations used for evaluation

Species | Transition | Frequency [GHz] | Line width [$km\,s^{-1}$] | Observation [Tmb] | Units
---|---|---|---|---|---
CS | 2,0 - 1,0 | 97.98095 | 0.64$\pm$0.07 | $1226.5\pm 0.1$ | mK
SO | 2,2 - 1,1 | 86.09395 | 0.42$\pm$0.01 | $223.7\pm 5.9$ | mK
| 2,3 - 1,2 | 99.29987 | 0.45$\pm$0.01 | $1422.5\pm 40.6$ | mK
| 3,1 - 2,1 | 109.2522 | 0.39$\pm$0.01 | $176.1\pm 5.2$ | mK
HCS+ | 2-1 | 85.34789 | 0.43$\pm$0.01 | $246.8\pm 6.1$ | mK
OCS | 6-5 | 72.97678 | 0.36$\pm$0.01 | $106.3\pm 6.8$ | mK
| 7-6 | 85.13910 | 0.38$\pm$0.01 | $87.4\pm 7.2$ | mK
| 8-7 | 97.30121 | 0.37$\pm$0.01 | $70.5\pm 5.4$ | mK
| 9-8 | 109.4631 | 0.34$\pm$0.04 | $49.4\pm 6.4$ | mK
o-H2CS | $3_{1,3}-2_{1,2}$ | 101.4778 | 0.44$\pm$0.01 | $558.4\pm 11.7$ | mK
| $3_{1,2}-2_{1,1}$ | 104.6170 | 0.44$\pm$0.01 | $514.3\pm 12.0$ | mK
p-H2CS | $3_{0,3}-2_{0,2}$ | 103.0405 | 0.45$\pm$0.02 | $536.9\pm 16.5$ | mK

Note. — Observations collected from (Vastel et al., 2014) and (Vastel et al.,
2018), ”o-” and ”p-” represent ortho- and para- version of species
respectively.

In order to give an example of , we run three inferences. One inference is on
mock data which were created by using UCLCHEM and RADEX, as these two codes
are used in to perform the inference. The second and third inference are for
the prestellar core L1544 (Caselli et al., 2002), once considering the
emission from only one molecular species and once with all sulfur bearing
species. The data we used for L1544 can be found in table 4 and were used to
infer the kinetic temperature, volume density, CR ionisation rate, and Rout.
This object is a very well studied prestellar core located at R.A. =
$05^{\mathrm{h}}01^{\mathrm{m}}11^{\mathrm{s}}.0$,
Dec=$25^{\circ}07^{\prime}00^{\prime\prime}$ (Caselli et al., 2002) (Vastel et
al. (2014), Punanova et al. (2018) and Vastel et al. (2018)).

We use the same input parameter space for all inferences. The exception is the
UV radiation field which we hold constant for the inferences on L1544 as we
expect the visual extinction to be sufficiently high for changes in the UV to
be negligible. The ranges for the physical parameters can be found in table 2.

###  3.1 Mock Data Inference

Figure 3: Posterior distribution function of the evaluation run performed on
mock data. The histograms represent the PDF of volume density, kinetic
temperature, UV field factor, Rout and the cosmic ray ionisation rate factor,
the colour bar shows the value ranges of the joint distribution functions. The
white dashed lines in the joint distributions, and the black dashed lines in
the PDFs represent the true value used to create the mock data.

First, we verify that performs as intended by creating mock data using the
same modeling codes that uses to perform an inference. We add Gaussian noise
to the data with a standard deviation of five percent for each emission line
as this would make the mock data errors on par, but slightly higher than, the
average of the uncertainties on the L1544 observational data. We do this
because running an inference where the true values are known and the data are
model generated allows us to test whether performs as intended when the models
are appropriate for to the data. As this is just an example case, and many
different combinations of chemicals and transition lines could be picked, we
choose a subset of emission lines from the observations we use for the
inferences on L1544. In order to create the mock data, we randomly chose
physical parameters that resulted in all emission lines having an observable
flux. The parameters we chose are as follows: Final volume density $1.0\times
10^{5}\,[\mathrm{cm}^{-3}]$, a kinetic gas temperature of 13 [K], radiation
field of 3 Habing, a cloud radius of $0.08\,\mathrm{pc}$, and a CR ionisation
rate value of $2.6\times 10^{-17}\,\mathrm{s}^{-1}$. The emission lines and
corresponding mock data values are found in table 3, which contains the exact
values of each line given by UCLCHEM and RADEX prior to adding noise, as well
as the data with Gaussian noise added to it and the corresponding
uncertainties.

Figure 4: The radiation temperature,TR, calculated by RADEX against the Energy
of the upper state, for the mock data and errors given to in black, and the
data created when using the most likely parameter values from the 1D
distributions from the inference of the mock data in blue. Red represents the
peak in the joint distribution of the CR ionisation rate and UV radiation
field while keeping the remaining parameters as they are for the previous
model, while green and fuchsia represent two additional points with values for
the CR ionisation rate and UV radiation field values in the elongated
distribution of likely values to show why the inference still gave some
importance to these values.

We run the inference, monitoring the chain of steps that each walker has
taken. The likelihood of accepting a new set of parameters decreases as a
function of the difference between the likelihood of the current model and the
new model. This means that over time, the parameter space that is being
traversed by all walkers, will decrease as the walkers find areas of parameter
space where the set of parameters produce models with a higher likelihood.
Once the walkers stop reducing this parameter space, we stop the inference.
Using these chains from the inference, we then create the posterior, shown in
Figure 3. The distributions contain the true values, which indicates that
works as expected. In order to validate this, we plot all mock observation
lines against the upper state energy, seen in Figure 4, and do the same for
the model values that are produced from ’s parameters with the highest
likelihoods in the 1D distributions. When we do this, we see that all but one
line lies within the uncertainties of the mock data.

We note that in the posteriors, there is a considerable degeneracy between the
UV field and the CR ionisation rates. Additionally, there is a clear peak in
the joint distribution of CR ionisation rate and UV radiation field. This peak
is at a CR ionisation rate equal to the galactic value (CR=1) and at a UV
radiation field strength of two Habing, however this peak does not have the
same value of the CR ionisation rate as the parameter set used to generate
Figure 4 as that takes the most likely value from the 1D marginalised
distributions rather than the overall most likely parameter set. To see how
the emission lines change along this extended distribution, and how the
observations look at this peak in the joint distribution, we include the
emission lines of this peak, and two additional combinations of CR ionisation
rate and UV radiation field strength in Figure 4, while holding all other
parameters constant. In looking at how the antenna temperature of the emission
lines compare between the models and the mock data, it becomes quite clear
that the values of the observations in this distribution all show significant
agreement with the mock data but that the peak in the CR ionisation rate and
UV radiation field strength distribution produces observations that fit better
than the model created using the most likely parameter values in the 1D
distribution.

###  3.2 Inferring the physical parameters of the pre-stellar core L1544

Figure 5: Posterior distribution function of the evaluation run performed on
the emission lines from OCS only. The histograms represent the PDF of volume
density, kinetic temperature, Rout and the cosmic ray ionisation rate factor,
the colour bar shows the value ranges of the joint distribution functions,
while the red dashed line in the PDF is the value with the highest
probability. Figure 6: TR over TR of OCS 6-5 against the upper state energy,
for emission lines of OCS found in table 4, compared to the data of the best
fit model after running an inference using only the OCS lines. All of the
lines fit the observed line ratios quite well. Black represents the real data
with error bars, while blue is the best fit model. Figure 7: TR against the
Energy of the upper state, for all emission lines in table 4, compared to the
data of the best fit model after running the stress test inference. While a
couple lines almost fit their observed counterparts, it is clear that is
unable to match all lines at once, which made it settle for a set of
parameters, that allow each line to at least get somewhat close to the
observations. Black represents the real data with error bars, while blue is
the best fit model. Figure 8: log($\chi^{2}$) grid for kinetic temperature and
volume density using column density from Vastel et al. (2018) for the six
species that are used for the MCMC Inference. The lower value of the
log($\chi^{2}$) is fixed at 0 to allow for better comparison between each
species while allowing a flexible upper end, as the large ranges of
log($\chi^{2}$) values make it difficult to make an informative Figure with a
single range of values.

With verification of how well can perform when using mock data, we now use
real observations in order to run another inference. The observations we use
are from Vastel et al. (2018), which which present observations for two
distinct regions in the L1544 object. One region is a methanol shell that is
around 8000 AU (Vastel et al., 2014) from the core and in this shell UV
photons can desorb methanol from the dust. The other region is a dust peak
situated at the center of the object. We perform two inferences on the dust
peak as there is a collection of sulphur bearing species where we start by
using only the emission lines of OCS. In this first inference, we start with
very broad priors and do not include additional information on the priors to
show how can perform. In an inference that is not designed to showcase the
performance, any prior knowledge would be used to inform the ranges of the
priors. We then follow that with an inference using all sulphur bearing
species, to serve as a test to inform us of how well of an inference can be
performed when is given unfavourable conditions. More chemical species and
emission lines are potentially unfavourable conditions, as , may struggle to
find a single set of parameters, that fit all lines at once. For reference of
values we expect the inference to estimate, we turn to Vastel et al. (2018)
who model the kinetic temperature and the volume density of the dust peak to
be around $~{}7\mathrm{K}$ and $~{}2\times 10^{6}\mathrm{cm}^{-3}$
respectively.

As this is an example case of how to use , we leave a large physical parameter
range for the volume density, Rout, and CR ionisation rate value. We limit the
kinetic temperature to be between 5 and 30 K, as at this temperature, a single
degree can make a difference to the diffusion and desorption rates of various
species, impacting the fractional abundances of different species. The only
two exceptions we make on limiting parameters is leaving the UV radiation
field strength at the default value for UCLCHEM, as it is not a parameter of
interest for the dust peak of a pre-stellar core, and setting the line width
to the error weighted mean of $0.37km\,s^{-1}$ for the OCS only inference.

We follow this, by using all of the chemical lines found in table 4 for a
second inference of the dust peak. We intentionally use all of these lines as
a stress test. For the second inference, we make the assumption that these
species trace the same substructure, which we emphasise in the inference by
setting all line widths to $1.0km\,s^{-1}$ in . This could lead to an
inference that is unable to fit the observations as could struggle to find one
set of parameters that lead to emission lines that match the observations.

The posterior of the limited inference, can be found in Figure 5. The
distribution has a very broad range in volume density and the CR ionisation
rate value, while having a strong peak in kinetic temperature and peaked area
in Rout. This suggests that there is a wide range of possible volume density
and CR ionisation rate values that can describe the observations well.

In order to choose a good fit, we use previously modeled values of the total
column density along with the fractional abundance of hydrogen to constrain
the gas volume density. Caselli et al. (2002) modeled a total column density
of $4.4\times 10^{22}\,[\mathrm{cm}^{-2}]$ which we combine with the peak
value of the Rout posterior to obtain a likely volume density of
$10^{6}\,[\mathrm{cm}^{-3}]$.

To validate that this is a good fit, we plot the emission line ratios, with
respect to the most intense line OCS 6-5, against the upper state energy, to
get Figure 6 to create a diagram analogous to a rotation diagram. This diagram
shows that the modelled line ratios, are within the estimated error bars of
the observed line ratios, which supports the accuracy of the inference
performed. A useful next step would be to remove volume density as a free
parameter, and use the measured column density to calculate it from Rout
during another round of inference, with a finer grid in parameter space. Since
this is just an example case, we will instead move on to the stress test of .

Prior to running this test, we calculate a $\chi^{2}$ fit of volume density
and kinetic temperature using only the radiative transfer code RADEX, to serve
as a baseline comparison to the performance of on the observed data, as this
is a more common approach. To perform this fit, we take the column densities,
determined by Vastel et al. (2018) through radiative transfer modeling, for
each species in table 4, and run RADEX on a grid of kinetic temperatures and
volume densities. Results of this fit can be seen in Figure 8. The $\chi^{2}$
fit is unable to find one set of parameters that agree with each other for all
lines. It also accepts a very large area of parameter space as potential fits
to each individual species, severely limiting how helpful this fit is to any
modeling effort. Beyond that, this method requires that we either provide a
column density estimate, or that we include a grid of column densities over
which to calculate, which would significantly increase the calculation time as
it would be adding an additional dimension to the parameter space. We note
however, that the speed at which these calculations was performed is at least
three orders of magnitude lower than a traditional MCMC inference that does
not use an SQL database.

We perform the stress test inference with the observational data by using all
species and emission lines found in table 4. As is the case with the
$\chi^{2}$ fit, the stress test inference is unable to match all lines at
once. The area onto which the MCMC inference converges is a delta-like
distribution on a single set of parameters that we then use to model the
emission lines. We again plot the emission line ratios against the upper state
energy, this time with respect to the SO (2,3)-(1,2) line as it is the
strongest line, resulting in Figure 7. In this Figure it is clear that while
one or two of the line ratios fit the observed ratios, the vast majority of
lines from the best fit model do not match the observations at all. This
failure is expected as assumes a simple homogeneous model should fit the
observations. As more species and transitions are added, the assumption of a
simple homogeneous model will be broken. We include this example of a failed
fit, to assist users of in understanding some of the limitations and more
importantly as a cautionary note when trying to fit multiple molecular
transitions with one single gas component. Beyond that, it is important to
analyse the best fit models and not just assume the posterior must be a good
fit.

##  4 Summary

The publicly available MCMC inference and SQL database managing tool, , is
capable of inferring physical parameters of astrochemical observations. This
paper presents the details necessary to understand the use, strengths and
shortcomings of this tool. The management of the database, using SQLite,
increases the efficiency of parameter inference as the tool is used. Using the
MCMC inference package, emcee, as well as having decoupled the chemical code
and radiative transfer code from the inference, also makes capable of handling
any other chemical modeling or radiative transfer modeling tool.

We showed the outputs of when inferring the physical parameters of mock data
created using UCLCHEM and RADEX, detailing just how well this recovered the
physical parameters of the mock data. The use of the SQL database in the
inference has showed that, once most models the inference looks for are in the
database, goes from taking $5185.33\pm 1041.96\,\mathrm{s}$ for ten walkers to
take one thousand steps to needing $68.89\pm 45.39\,\mathrm{s}$ which is a
significant decrease in computational time. When inferring the physical
parameters of actual observations, we detailed some of the issues that must be
taken into consideration when running this tool. Users should be aware that if
they keep the physical parameter ranges too small, then the inference may not
be able to find matching parameters, resulting in non physical answers. We
intend to add a fast prior predictive checking functionality to .
Additionally, giving too many emission lines, without taking into
consideration that they may arise from separate structures, or that the
combination of emission lines require physical parameters outside of the
inference range, can lead to being unable to find physical parameters that
match all lines. Because of this, we advise caution on using a long list of
emission lines without first studying if those lines come from regions within
the object that have similar physical parameters, as this tool will assume
they all come from one structure with one set of physical parameters. When
taking these factors into consideration, can be a great asset in inferring
physical parameter ranges in which to start modeling astrochemical
environments.

##  5 Acknowledgement

This project has received funding from the European Union’s Horizon 2020
research and innovation programme under the Marie Skłodowska-Curie grant
agreement No 811312 for the project ”Astro-Chemical Origins” (ACO) as well as
from the European Research Council (ERC) under the European Union’s Horizon
2020 research and innovation programme MOPPEX 833460.

## References

  * Allodi et al. (2013) Allodi, M., Baragiola, R., Baratta, G., et al. 2013, Space Science Reviews, 180, 101, doi: 10.1007/S11214-013-0020-8
  * Caselli et al. (1997) Caselli, P., Hartquist, T. W., & Havnes, O. 1997, A&A, 322, 296
  * Caselli et al. (2002) Caselli, P., Walmsley, C. M., Zucconi, A., et al. 2002, The Astrophysical Journal, 565, 331, doi: 10.1086/324301
  * de Mijolla, D. et al. (2019) de Mijolla, D., Viti, S., Holdship, J., Manolopoulou, I., & Yates, J. 2019, A&A, 630, A117, doi: 10.1051/0004-6361/201935973
  * Foreman-Mackey et al. (2013) Foreman-Mackey, D., Hogg, D. W., Lang, D., & Goodman, J. 2013, Publications of the Astronomical Society of the Pacific, 125, 306–312, doi: 10.1086/670067
  * Goodman & Weare (2010) Goodman, J., & Weare, J. 2010, Communications in Applied Mathematics and Computational Science, 5, 65, doi: 10.2140/camcos.2010.5.65
  * Harada et al. (2019) Harada, N., Nishimura, Y., Watanabe, Y., et al. 2019, ApJ, 871, 238, doi: 10.3847/1538-4357/aaf72a
  * Holdship et al. (2017) Holdship, J., Viti, S., Jiménez-Serra, I., Makrymallis, A., & Priestley, F. 2017, The Astronomical Journal, 154, 38, doi: 10.3847/1538-3881/aa773f
  * Holdship et al. (2019) Holdship, J., Viti, S., Codella, C., et al. 2019, The Astrophysical Journal, 880, 138, doi: 10.3847/1538-4357/ab1f8f
  * McElroy, D. et al. (2013) McElroy, D., Walsh, C., Markwick, A. J., et al. 2013, A&A, 550, A36, doi: 10.1051/0004-6361/201220465
  * Nelson et al. (2013) Nelson, B., Ford, E. B., & Payne, M. J. 2013, The Astrophysical Journal Supplement Series, 210, 11, doi: 10.1088/0067-0049/210/1/11
  * Punanova et al. (2018) Punanova, A., Caselli, P., Feng, S., et al. 2018, The Astrophysical Journal, 855, 112, doi: 10.3847/1538-4357/aaad09
  * Schöier et al. (2005) Schöier, van der Tak, F. F. S., van Dishoeck, E. F., & Black, J. H. 2005, A&A, 432, 369, doi: 10.1051/0004-6361:20041729
  * Taquet et al. (2012) Taquet, V., Ceccarelli, C., & Kahane, C. 2012, Astronomy & Astrophysics, 538, A42, doi: 10.1051/0004-6361/201117802
  * ter Braak & Vrugt (2008) ter Braak, C., & Vrugt, J. 2008, Statistics and Computing, 18, 435, doi: 10.1007/s11222-008-9104-9
  * van der Tak et al. (2007) van der Tak, F. F. S., Black, J. H., Schöier, F. L., Jansen, D. J., & van Dishoeck, E. F. 2007, Astronomy & Astrophysics, 468, 627–635, doi: 10.1051/0004-6361:20066820
  * Vastel et al. (2014) Vastel, C., Ceccarelli, C., Lefloch, B., & Bachiller, R. 2014, The Astrophysical Journal, 795, L2, doi: 10.1088/2041-8205/795/1/l2
  * Vastel et al. (2018) Vastel, C., Quénard, D., Le Gal, R., et al. 2018, Monthly Notices of the Royal Astronomical Society, 478, 5514–5532, doi: 10.1093/mnras/sty1336
  * Viti (2017) Viti, S. 2017, Astronomy & Astrophysics, 607, A118, doi: 10.1051/0004-6361/201628877
  * Wakelam et al. (2012) Wakelam, V., Herbst, E., Loison, J.-C., et al. 2012, The Astrophysical Journal Supplement Series, 199, 21, doi: 10.1088/0067-0049/199/1/21